Пример #1
0
        public async Task GetJsonAsync_Should_Return_User_Json_With_Same_IdAsync(string username, DbJson dbJson, JsonModel jsonModel)
        {
            Expression <Func <DbJson, bool> > expression = null;

            _mongoCollectionClient
            .When(x => x.FindOneAsync(username, Arg.Any <Expression <Func <DbJson, bool> > >()))
            .Do(info => { expression = (Expression <Func <DbJson, bool> >)info[1]; });
            _mongoCollectionClient
            .FindOneAsync(username, Arg.Any <Expression <Func <DbJson, bool> > >())
            .Returns(dbJson);
            _mapper.Map <JsonModel>(dbJson).Returns(jsonModel);

            var result = await _jsonRepositoryInstance.GetJsonAsync(username, dbJson.Id);

            Expression <Func <DbJson, bool> > expectedExpression = x => x.Id == dbJson.Id;

            Assert.AreEqual(jsonModel, result);
            Assert.IsTrue(Lambda.Eq(expectedExpression, expression));
        }