コード例 #1
0
        public void SomethingElseCreateInteractor_CreateSomethingElse_PersistsSomethingElseWithName()
        {
            Mock <ISomethingFactory>     mockSomethingFactory     = new Mock <ISomethingFactory>();
            Mock <ISomethingElseFactory> mockSomethingElseFactory = new Mock <ISomethingElseFactory>();

            mockSomethingElseFactory.Setup(x => x.Create(somethingElse.Name)).Returns(somethingElse);
            Mock <ISomethingElsePersistence> mockPersistence         = new Mock <ISomethingElsePersistence>();
            SomethingElseCreateInteractor    somethingElseInteractor = new SomethingElseCreateInteractor(mockSomethingFactory.Object, mockSomethingElseFactory.Object, mockPersistence.Object);

            somethingElseInteractor.CreateSomethingElse(somethingElse.Name);

            mockPersistence.Verify(x => x.SaveSomethingElse(somethingElse));
        }
コード例 #2
0
        public void SomethingElseCreateInteractor_CreateSomethingElse_PersistsSomethingElseWithSomethings()
        {
            var name           = "Fred Bloggs";
            var somethingElse1 = Domain.SomethingElse.CreateNamedSomethingElse(name);
            Mock <ISomethingFactory> mockSomethingFactory = new Mock <ISomethingFactory>();

            mockSomethingFactory.Setup(x => x.Create(something.Name)).Returns(something);
            Mock <ISomethingElseFactory> mockSomethingElseFactory = new Mock <ISomethingElseFactory>();

            mockSomethingElseFactory.Setup(x => x.Create(somethingElse1.Name)).Returns(somethingElse1);
            Mock <ISomethingElsePersistence> mockPersistence         = new Mock <ISomethingElsePersistence>();
            SomethingElseCreateInteractor    somethingElseInteractor = new SomethingElseCreateInteractor(mockSomethingFactory.Object, mockSomethingElseFactory.Object, mockPersistence.Object);

            string[] othernames = { "Alice Bloggs" };
            somethingElseInteractor.CreateSomethingElse(name, othernames);

            mockPersistence.Verify(x => x.SaveSomethingElse(somethingElse1));
        }