public void SubFixture_LocateTypeWithInterface_ReturnsInstance() { var fixture = new SubFixture(); var instance = fixture.Locate <ImportSomeInterface>(); Assert.NotNull(instance); Assert.Equal(0, instance.SomeValue); }
public void SubFixture_SubstituteAndLocateTypeWithInterface_ReturnsInstance() { var fixture = new SubFixture(); fixture.Locate <ISomeInterface>().SomeIntMethod().Returns(10); var instance = fixture.Locate <ImportSomeInterface>(); Assert.NotNull(instance); Assert.Equal(10, instance.SomeValue); }
public void SubFixture_SubstituteDefaultSingletonFalseAndSingleton_ReturnsSingleton() { var fixture = new SubFixture(defaultSingleton: false); fixture.Substitute <ISomeInterface>(s => s.SomeIntMethod().Returns(20), singleton: true); var instance = fixture.Substitute <ISomeInterface>(s => s.SomeIntMethod().Returns(10)); Assert.NotNull(instance); Assert.Equal(10, instance.SomeIntMethod()); Assert.Equal(20, fixture.Substitute <ISomeInterface>(singleton: true).SomeIntMethod()); }
public void SubFixture_SubstituteDefaultSingletonFalse_ReturnsCorrectImplementations() { var fixture = new SubFixture(defaultSingleton: false); var instance = fixture.Substitute <ISomeInterface>(s => s.SomeIntMethod().Returns(10)); Assert.NotNull(instance); var instance2 = fixture.Substitute <ISomeInterface>(s => s.SomeIntMethod().Returns(15)); Assert.NotNull(instance2); Assert.Equal(0, fixture.Locate <ISomeInterface>().SomeIntMethod()); Assert.Equal(15, instance2.SomeIntMethod()); Assert.Equal(10, instance.SomeIntMethod()); Assert.Equal(0, fixture.Locate <ISomeInterface>().SomeIntMethod()); }