public void DnaRepository_GetByChainString_ChainDoesNotExist_Succeeds() { //Arrange DnaRepository repository = GetDnaRepository(); Mock <ISession> sessionMock = new Mock <ISession>(); IList <Dna> list = new List <Dna>() { new Dna() { ChainString = "AAA,CCC,TTT" }, new Dna() { ChainString = "CCC,CCC,TTT" }, new Dna() { ChainString = "TTT,TTT,TTT" } }; string chain = "AAA,AAA,AAA"; _dnaDaoMock.Setup(x => x.GetAll(It.IsAny <ISession>())).Returns(list.AsQueryable()).Verifiable(); //Action Dna result = repository.GetByChainString(sessionMock.Object, chain); //Asserts Assert.IsNull(result); _dnaDaoMock.Verify(x => x.GetAll(It.IsAny <ISession>()), Times.Once); }
public void DnaRepository_GetByChainString_ChainDoesExist_Succeeds() { //Arrange DnaRepository repository = GetDnaRepository(); Mock <ISession> sessionMock = new Mock <ISession>(); Guid foundId = Guid.NewGuid(); IList <Dna> list = new List <Dna>() { new Dna() { ChainString = "AAA,CCC,TTT" }, new Dna() { Id = foundId, ChainString = "CCC,CCC,TTT" }, new Dna() { ChainString = "TTT,TTT,TTT" } }; string chain = "CCC,CCC,TTT"; //second one _dnaDaoMock.Setup(x => x.GetAll(It.IsAny <ISession>())).Returns(list.AsQueryable()).Verifiable(); //Action Dna result = repository.GetByChainString(sessionMock.Object, chain); //Asserts Assert.IsNotNull(result); Assert.AreEqual(foundId, result.Id); Assert.AreEqual(chain, result.ChainString); _dnaDaoMock.Verify(x => x.GetAll(It.IsAny <ISession>()), Times.Once); }