示例#1
0
        public void InsertHumanDna()
        {
            //ARRANGE
            var dna = new string[]
            {
                "ATGCGA", "CAGTGC", "TTATGT", "AGAAGG", "CCCCTA", "TCACTG"
            };

            var humanDna = new HumanDna(dna)
            {
                IsMutant = true
            };

            var mockDnaData = _autoMoqer.GetMock <IMongoCollection <DnaData> >();

            mockDnaData.Setup(x => x.InsertOneAsync(It.IsAny <DnaData>(), It.IsAny <InsertOneOptions>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <object>(null));

            var mockDbContext = _autoMoqer.GetMock <IDbContext>();

            mockDbContext.Setup(x => x.Dna)
            .Returns(mockDnaData.Object);

            //ACT
            _dnaRepository.Insert(humanDna);

            //ASSERT
            mockDnaData.Verify(x => x.InsertOneAsync(It.IsAny <DnaData>(), It.IsAny <InsertOneOptions>(), It.IsAny <CancellationToken>()), Times.Once);
        }
示例#2
0
        public async Task <bool> Evaluate(string[] dna)
        {
            var humanDna = (HumanDna)_dnaBuilder.AddDna(dna, DnaType.Human).Build();

            humanDna.IsMutant = _dnaEvaluator.IsMutant(humanDna);

            await _dnaRepository.Insert(humanDna);

            return(humanDna.IsMutant);
        }