Пример #1
0
        public void DnaService_GetByChainAsync_WrongParameters_Fails()
        {
            //Arrange
            DnaService service = GetDnaService();

            string[] emptyArray = { };

            //Action && Asserts
            Assert.ThrowsExceptionAsync <ArgumentException>(() => service.GetByChainAsync(null));
            Assert.ThrowsExceptionAsync <ArgumentException>(() => service.GetByChainAsync(emptyArray));
        }
Пример #2
0
        public async Task DnaService_GetByChainAsync_ValidArray_Succeeds()
        {
            //Arrange
            DnaService service = GetDnaService();

            string[] chain = { "AA", "CC" };

            Dna dna = new Dna()
            {
                Id          = Guid.NewGuid(),
                ChainString = "AA,CC",
                IsMutant    = false
            };

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

            //Action
            Dna result = await service.GetByChainAsync(chain);

            //Asserts
            Assert.IsNotNull(result);
            _sessionFactoryMock.Verify(x => x.OpenSession(), Times.Once);
            _dnaRepositoryMock.Verify(x => x.GetByChainString(It.IsAny <ISession>(), It.IsAny <string>()), Times.Once);
        }