public async void GetProtocol_Valid_IsProtocol_Test() { //Arrange const int idToRead = 0; _repositoryMock.Setup(r => r.Read(idToRead)).Returns(Task.FromResult(_storedProtocol)); var protocolAdapter = new ProtocolAdapter(_repositoryMock.Object); //Act var returnedProtocol = await protocolAdapter.Read(idToRead); //Assert Assert.IsInstanceOfType(returnedProtocol, typeof(Protocol)); }
public void CreateProtocol_Success_Test() { //Arrange const int expectedReturnId = 0; _repositoryMock.Setup(r => r.Create(_storedProtocol)).Returns(Task.FromResult(expectedReturnId)); var protocolAdapter = new ProtocolAdapter(_repositoryMock.Object); //Act var actualId = protocolAdapter.Read(_storedProtocol.Id).Id; //Assert Assert.IsTrue(expectedReturnId == actualId); }
public async void GetProtocol_Valid_CorrectProtocolInfo_Test() { //Arrange const int idToRead = 0; _repositoryMock.Setup(r => r.Read(idToRead)).Returns(Task.FromResult(_storedProtocol)); var adapter = new ProtocolAdapter(_repositoryMock.Object); //Act var actualProtocol = await adapter.Read(idToRead); //Assert Assert.IsTrue(_protocol.StudyName == actualProtocol.StudyName); // TODO add more? }
public void GetAllProtocols_Valid_ReturnsCorrectProtocols_Test() { // TODO add property values //Arrange var protocol1 = new StoredProtocol {}; var protocol2 = new StoredProtocol {}; var protocol3 = new StoredProtocol {}; var protocolList = new List<StoredProtocol> { protocol1, protocol2, protocol3 }.AsQueryable(); _repositoryMock.Setup(r => r.Read()).Returns(protocolList); var adapter = new ProtocolAdapter(_repositoryMock.Object); //Act var result = adapter.Read(); var actualProtocols = result.ToList(); //Assert var counter = 0; foreach (var actualProtocol in protocolList.AsEnumerable()) { var returnedProtocol = actualProtocols[counter]; // Todo add property asserts Assert.IsTrue(returnedProtocol.StudyName == actualProtocol.StudyName); counter++; } }
public void GetAllProtocols_Valid_ReturnsCorrectNumberOfProtocols_Test() { //Arrange var protocol1 = new StoredProtocol { }; var protocol2 = new StoredProtocol { }; var protocol3 = new StoredProtocol { }; var protocolList = new List<StoredProtocol> { protocol1, protocol2, protocol3 }.AsQueryable(); _repositoryMock.Setup(r => r.Read()).Returns(protocolList); var adapter = new ProtocolAdapter(_repositoryMock.Object); const int expectedCount = 3; //Act var result = adapter.Read(); var actualCount = result.ToList().Count; //Assert Assert.IsTrue(expectedCount == actualCount); }
public async void GetProtocol_Invalid_NoExistingProtocol_Test() { //Arrange const int idToRead = 0; _repositoryMock.Setup(r => r.Read(idToRead)); var adapter = new ProtocolAdapter(_repositoryMock.Object); //Act var returnedProtocol = await adapter.Read(idToRead); //Assert Assert.IsNull(returnedProtocol); }