public async Task AddJsonAsync_Should_Add_One_JsonAsync(string username, DbJson dbJson, JsonModel jsonModel) { _mapper.Map <DbJson>(jsonModel).Returns(dbJson); await _jsonRepositoryInstance.AddJsonAsync(username, jsonModel); await _mongoCollectionClient.Received(1).InsertOneAsync(username, dbJson); }
public void DbJson_To_JsonModel_Mapping_Should_Work_Correctly(DbJson dbJson) { var jsonModel = _mapper.Map <JsonModel>(dbJson); Assert.AreEqual(dbJson.Id, jsonModel.Id); Assert.AreEqual(dbJson.Created, jsonModel.Created); Assert.AreEqual(dbJson.Updated, jsonModel.Updated); Assert.AreEqual(dbJson.Name, jsonModel.Name); Assert.AreEqual(dbJson.Json, jsonModel.Json); }
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)); }