public void GetPaperArchieveReturnsNullTest() { //Arrange var mockPaperArchieveService = new Mock <IPaperArchieveService>(); var mockPaperArchieveDAL = new Mock <IPaperArchieveDAL>(); mockPaperArchieveDAL.Setup(x => x.Get(It.IsAny <Guid>())).Returns((PaperArchieve)null); mockPaperArchieveService.Setup(x => x.Get(It.IsAny <Guid>())).Returns((PaperArchieve)null); //Act PaperArchieveService paperServiceArchieve = new PaperArchieveService(mockPaperArchieveDAL.Object); var result = paperServiceArchieve.Get(new Guid()); //Assert Assert.IsNull(result); }
public void GetPaperArchieveReturnsExceptionTest() { //Arrange var mockPaperArchieveService = new Mock <IPaperArchieveService>(); var mockPaperArchieveDAL = new Mock <IPaperArchieveDAL>(); mockPaperArchieveDAL.Setup(x => x.Get(It.IsAny <Guid>())).Throws(new Exception()); mockPaperArchieveService.Setup(x => x.Get(It.IsAny <Guid>())).Throws(new Exception()); //Act PaperArchieveService paperServiceArchieve = new PaperArchieveService(mockPaperArchieveDAL.Object); var result = paperServiceArchieve.Get(new Guid()); //Assert //Expected exception was thrown }
public void GetPaperArchieveSuccessfulTest() { //Arrange PaperArchieve expectedPaper = new PaperArchieve() { Id = new Guid(), PaperId = new Guid(), FileName = "Sample File", Location = "Sample Location" }; var mockPaperArchieveService = new Mock <IPaperArchieveService>(); var mockPaperArchieveDAL = new Mock <IPaperArchieveDAL>(); mockPaperArchieveDAL.Setup(x => x.Get(It.IsAny <Guid>())).Returns(expectedPaper); mockPaperArchieveService.Setup(x => x.Get(It.IsAny <Guid>())).Returns(expectedPaper); //Act PaperArchieveService paperServiceArchieve = new PaperArchieveService(mockPaperArchieveDAL.Object); var result = paperServiceArchieve.Get(new Guid()); //Assert Assert.AreSame(expectedPaper, result); }