Пример #1
0
        public void NotRegisteredServiceThrows()
        {
            // Arrange
            IViewServiceRepository repo = new ViewServiceRepository();

            // Act

            // Assert
            ExceptionAssert.Throws <InvalidOperationException, object>(() => repo.Execute <IDummyService>());
        }
Пример #2
0
        public void NotRegisteredServiceThrows()
        {
            // Arrange
            IViewServiceRepository repo = new ViewServiceRepository();

            // Act

            // Assert
            ExceptionAssert.Throws<InvalidOperationException, object>( () => repo.Execute<IDummyService>() );
        }
Пример #3
0
        public void ServiceResultIsCasted()
        {
            // Arrange
            var serviceMock = new Mock<IViewService>();
            serviceMock.Setup( s => s.Execute( It.IsAny<MetroWindow>(), It.IsAny<object>() ) ).Returns( Task.FromResult( (object)123 ) );

            IViewServiceRepository repo = new ViewServiceRepository();
            repo.Register<IDummyService>( serviceMock.Object );

            // Act
            int result = repo.Execute<IDummyService, int>().Result;

            // Assert
            Assert.AreEqual( 123, result );
            serviceMock.VerifyAll();
        }
Пример #4
0
        public void ServiceResultIsCasted()
        {
            // Arrange
            var serviceMock = new Mock <IViewService>();

            serviceMock.Setup(s => s.Execute(It.IsAny <MetroWindow>(), It.IsAny <object>())).Returns(Task.FromResult((object)123));

            IViewServiceRepository repo = new ViewServiceRepository();

            repo.Register <IDummyService>(serviceMock.Object);

            // Act
            int result = repo.Execute <IDummyService, int>().Result;

            // Assert
            Assert.AreEqual(123, result);
            serviceMock.VerifyAll();
        }