public void Create_with_invalid_data() { // arrange var mclient = GetMockClient(out Mock <IMongoCollection <PasswordStoreModel> > mcollection); var mrepo = new PassStoreMongo(mclient.Object); // act // assert Assert.Throws <ArgumentNullException>(() => mrepo.Create(null) .GetAwaiter().GetResult()); }
public void Create_with_valid_data() { // arrange var mclient = GetMockClient(out Mock <IMongoCollection <PasswordStoreModel> > mcollection); var mrepo = new PassStoreMongo(mclient.Object); // act var model = new PasswordStoreModel() { Key = "key-1", Name = "name-1", PassPhrase = "somepwd" }; var rslt = mrepo.Create(model) .GetAwaiter().GetResult(); // assert mclient.VerifyAll(); mcollection.Verify(mc => mc.FindAsync(It.IsAny <FilterDefinition <PasswordStoreModel> >(), default(FindOptions <PasswordStoreModel>), default(CancellationToken)), Times.Once); mcollection.Verify(mc => mc.InsertOneAsync(model, default(InsertOneOptions), default(CancellationToken)), Times.Once); }