Skip to content

Commit

Permalink
Merge pull request #2757 from FirelyTeam/feature/migrate-to-nsubstitude
Browse files Browse the repository at this point in the history
replaced moq with NSubstitute
  • Loading branch information
mmsmits authored Apr 4, 2024
2 parents 1cfaad6 + f7afb93 commit 2ad3c09
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 167 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

using FluentAssertions;
using Hl7.Fhir.Model;
using Hl7.Fhir.Rest;
using Hl7.Fhir.Serialization;
using Hl7.Fhir.Specification.Navigation;
using Hl7.Fhir.Specification.Snapshot;
Expand All @@ -22,8 +21,8 @@
using Hl7.Fhir.Support;
using Hl7.Fhir.Utility;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using System;
using NSubstitute;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
Expand Down Expand Up @@ -200,9 +199,9 @@ public async T.Task OverriddenNestedStructureDefinitionLists()
});
derivedSD.BaseDefinition = baseSD.Url;

var resourceResolver = new Mock<IResourceResolver>();
resourceResolver.Setup(resolver => resolver.ResolveByCanonicalUri(It.IsAny<string>())).Returns(baseSD);
var snapshotGenerator = new SnapshotGenerator(resourceResolver.Object, new SnapshotGeneratorSettings());
var resourceResolver = Substitute.For<IResourceResolver>();
resourceResolver.ResolveByCanonicalUri(Arg.Any<string>()).Returns(baseSD);
var snapshotGenerator = new SnapshotGenerator(resourceResolver, new SnapshotGeneratorSettings());
await snapshotGenerator.UpdateAsync(derivedSD);

derivedSD.Snapshot.Element.Single(element => element.Path == "Practitioner.identifier").Slicing.Discriminator.First().Path.Should().Be(discriminatorPath, "The discriminator should be copied from base");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Hl7.Fhir.Specification.Summary;
using Hl7.Fhir.Utility;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using NSubstitute;
using System;
using System.Diagnostics;
using System.IO;
Expand Down Expand Up @@ -440,11 +440,11 @@ public void TestErrorSummaries()
public void TestIsConformanceSummary(bool typeNameFound)
{
object value = typeNameFound ? "unknownTypeName" : null;
var propertiesMock = new Mock<IArtifactSummaryPropertyBag>();
var propertiesMock = Substitute.For<IArtifactSummaryPropertyBag>();

propertiesMock.Setup(p => p.TryGetValue(ArtifactSummaryProperties.TypeNameKey, out value)).Returns(typeNameFound);
propertiesMock.TryGetValue(ArtifactSummaryProperties.TypeNameKey, out value).Returns(typeNameFound);

var result = propertiesMock.Object.IsConformanceSummary();
var result = propertiesMock.IsConformanceSummary();

result.Should().BeFalse();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
using Hl7.Fhir.Support;
using Hl7.Fhir.Utility;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using NSubstitute;
using NSubstitute.Exceptions;
using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand Down Expand Up @@ -205,9 +206,9 @@ public async T.Task OverriddenNestedStructureDefinitionLists()
});
derivedSD.BaseDefinition = baseSD.Url;

var resourceResolver = new Mock<IResourceResolver>();
resourceResolver.Setup(resolver => resolver.ResolveByCanonicalUri(It.IsAny<string>())).Returns(baseSD);
var snapshotGenerator = new SnapshotGenerator(resourceResolver.Object, new SnapshotGeneratorSettings());
var resourceResolver = Substitute.For<IResourceResolver>();
resourceResolver.ResolveByCanonicalUri(Arg.Any<string>()).Returns(baseSD);
var snapshotGenerator = new SnapshotGenerator(resourceResolver, new SnapshotGeneratorSettings());
await snapshotGenerator.UpdateAsync(derivedSD);

derivedSD.Snapshot.Element.Single(element => element.Path == "Practitioner.identifier").Slicing.Discriminator.First().Path.Should().Be(discriminatorPath, "The discriminator should be copied from base");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Hl7.Fhir.Specification.Summary;
using Hl7.Fhir.Utility;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using NSubstitute;
using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand Down Expand Up @@ -486,11 +486,11 @@ public void TestErrorSummaries()
public void TestIsConformanceSummary(bool typeNameFound)
{
object value = typeNameFound ? "unknownTypeName" : null;
var propertiesMock = new Mock<IArtifactSummaryPropertyBag>();
var propertiesMock = Substitute.For<IArtifactSummaryPropertyBag>();

propertiesMock.Setup(p => p.TryGetValue(ArtifactSummaryProperties.TypeNameKey, out value)).Returns(typeNameFound);
propertiesMock.TryGetValue(ArtifactSummaryProperties.TypeNameKey, out value).Returns(typeNameFound);

var result = propertiesMock.Object.IsConformanceSummary(ModelInfo.ModelInspector);
var result = propertiesMock.IsConformanceSummary(ModelInfo.ModelInspector);

result.Should().BeFalse();
}
Expand Down
Loading

0 comments on commit 2ad3c09

Please sign in to comment.