Exemplo n.º 1
0
        public void ReadWithIdShouldReturnOkWhenReadOperationSucceeded()
        {
            var loggerMock     = new Mock <ILogger>();
            var repositoryMock = new Mock <IRepository <SampleEntity> >();
            var requestObject  = 1;

            loggerMock.Setup(v => v.Error(It.IsAny <string>()));
            repositoryMock.Setup(v => v.Read(requestObject)).Returns(new SampleEntity());
            var service = new SampleService(loggerMock.Object, repositoryMock.Object);

            // When
            var result = service.Read(requestObject);

            // Then
            Assert.True(result.IsSuccessed);
        }
Exemplo n.º 2
0
        public void ReadWithGuidShouldReturnNotOkWhenReadOperationFailed()
        {
            var loggerMock     = new Mock <ILogger>();
            var repositoryMock = new Mock <IRepository <SampleEntity> >();
            var requestObject  = new Guid("2d62fa93-1be2-4e71-a8df-531b2fc278c3");

            loggerMock.Setup(v => v.Error(It.IsAny <string>()));
            repositoryMock.Setup(v => v.Read(requestObject));
            var service = new SampleService(loggerMock.Object, repositoryMock.Object);

            // When
            var result = service.Read(requestObject);

            // Then
            Assert.False(result.IsSuccessed);
        }