public void NotRegisteredServiceThrows() { // Arrange IViewServiceRepository repo = new ViewServiceRepository(); // Act // Assert ExceptionAssert.Throws <InvalidOperationException, object>(() => repo.Execute <IDummyService>()); }
public void NotRegisteredServiceThrows() { // Arrange IViewServiceRepository repo = new ViewServiceRepository(); // Act // Assert ExceptionAssert.Throws<InvalidOperationException, object>( () => repo.Execute<IDummyService>() ); }
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(); }
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(); }