Пример #1
0
        public void MoqExtension()
        {
            DependencyInjectionContainer container = new DependencyInjectionContainer();

            container.Moq();

            container.Configure(c => c.Export<ImportConstructor>());

            ImportConstructor importConstructor = container.Locate<ImportConstructor>();

            Assert.NotNull(importConstructor);
            Assert.NotNull(importConstructor.BasicService);
        }
Пример #2
0
        public void SetupExample()
        {
            DependencyInjectionContainer container = new DependencyInjectionContainer();

            container.Moq();

            container.Configure(c => c.Export<ImportConstructor>());

            container.Locate<Mock<IBasicService>>().Setup(x => x.SomeMethod()).Returns(5);

            ImportConstructor importConstructor = container.Locate<ImportConstructor>();

            Assert.NotNull(importConstructor);
            Assert.NotNull(importConstructor.BasicService);

            Assert.Equal(5, importConstructor.BasicService.SomeMethod());
        }
Пример #3
0
        public void ConfigureExample()
        {
            DependencyInjectionContainer container = new DependencyInjectionContainer();

            container.Moq();

            container.Configure(c =>
                                    {
                                        c.Export<ImportConstructor>();
                                              c.Moq<IBasicService>().Arrange(mock => mock.Setup(y => y.SomeMethod()).Returns(5));
                                    });

            ImportConstructor importConstructor = container.Locate<ImportConstructor>();

            Assert.NotNull(importConstructor);

            Assert.Equal(5, importConstructor.SomeMethod());
        }