예제 #1
0
        public void FakeFixture_DefaultSingletonFalse_ReturnsCorrectInstance()
        {
            var fixture = new FakeFixture(defaultSingleton: false);

            var instance1 = fixture.Fake <ISomeInterface>(x => A.CallTo(() => x.SomeIntMethod()).Returns(10));

            var instance2 = fixture.Fake <ISomeInterface>(x => A.CallTo(() => x.SomeIntMethod()).Returns(15));

            Assert.Equal(0, fixture.Locate <ISomeInterface>().SomeIntMethod());

            Assert.Equal(10, instance1.SomeIntMethod());

            Assert.Equal(15, instance2.SomeIntMethod());

            Assert.Equal(0, fixture.Locate <ISomeInterface>().SomeIntMethod());
        }
예제 #2
0
        public void FakeFixture_LocateTypeWithInterface_ReturnsInstance()
        {
            var fixture = new FakeFixture();

            var instance = fixture.Locate <ImportSomeInterface>();

            Assert.NotNull(instance);
            Assert.Equal(0, instance.SomeValue);
        }
예제 #3
0
        public void FakeFixture_FakeAndLocateTypeWithInterface_ReturnsInstance()
        {
            var fixture = new FakeFixture();

            fixture.Fake <ISomeInterface>(f => A.CallTo(() => f.SomeIntMethod()).Returns(10));

            var instance = fixture.Locate <ImportSomeInterface>();

            Assert.NotNull(instance);
            Assert.Equal(10, instance.SomeValue);
        }