public void AddStoreItem_with_invalid_data() { // arrange var mclient = GetMockClient(out Mock <IMongoCollection <PasswordStoreModel> > mcollection); var mrepo = new PassStoreMongo(mclient.Object); // act and assert Assert.Throws <ArgumentNullException>(() => mrepo.AddStoreItem("", new StoreItemModel() { Title = "title", UserName = "******", Password = "******" }) .GetAwaiter().GetResult()); Assert.Throws <ArgumentNullException>(() => mrepo.AddStoreItem("key-1", default(StoreItemModel)) .GetAwaiter().GetResult()); }
public void AddStoreItem_with_valid_store_model() { // arrange var mclient = GetMockClient(out Mock <IMongoCollection <PasswordStoreModel> > mcollection); var mrepo = new PassStoreMongo(mclient.Object); // act var rslt = mrepo.AddStoreItem("key-1", new StoreItemModel() { Title = "title", UserName = "******", Password = "******" }) .GetAwaiter().GetResult(); // assert mclient.VerifyAll(); mcollection.Verify(mc => mc.UpdateOneAsync(It.IsAny <FilterDefinition <PasswordStoreModel> >(), It.IsAny <UpdateDefinition <PasswordStoreModel> >(), default(UpdateOptions), default(CancellationToken)), Times.Exactly(2)); }