Exemplo n.º 1
0
        public void DnaService_SaveAsync_WrongParameters_Fails()
        {
            //Arrange
            DnaService service = GetDnaService();

            //Action && Asserts
            Assert.ThrowsExceptionAsync <ArgumentException>(() => service.SaveAsync(null));
        }
Exemplo n.º 2
0
        public async Task DnaService_SaveAsync_EmptyCollection_Succeeds()
        {
            //Arrange
            DnaService        service = GetDnaService();
            ICollection <Dna> dnas    = new List <Dna>();

            _dnaRepositoryMock.Setup(x => x.GetByChainString(It.IsAny <ISession>(), It.IsAny <string>())).Returns(new Dna()).Verifiable();
            _dnaRepositoryMock.Setup(x => x.Save(It.IsAny <ISession>(), It.IsAny <Dna>())).Verifiable();

            //Action
            await service.SaveAsync(dnas);

            //Asserts
            _sessionFactoryMock.Verify(x => x.OpenSession(), Times.Once);
            _sessionMock.Verify(x => x.BeginTransaction(), Times.Once);
            _transactionMock.Verify(x => x.Commit(), Times.Once);
            _dnaRepositoryMock.Verify(x => x.GetByChainString(It.IsAny <ISession>(), It.IsAny <string>()), Times.Never);
            _dnaRepositoryMock.Verify(x => x.Save(It.IsAny <ISession>(), It.IsAny <Dna>()), Times.Never);
        }