public void UpdateAssoicatedCollection_RemoveEntityFromCollection_SlaveSide_ValidateOtherCollectionUpdated()
        {
            var bulkUpdaterMock = new BulkUpdaterMock();

            bulkUpdaterMock.AddMockResponse(new BulkResponseRow("1", "2-123-Updated", null, null));

            var couchDBClientMock = new CouchDBClientAdapterMock(RawResponseWithOneTenant, bulkUpdaterMock);
            var subject           = ContextTestHelper.BuildContextForTest(couchDBClientMock);
            var userToUpdate      = subject.View <UserModel>("fake_not_used")
                                    .AssociatedCollection(x => x.Tenants, 1)
                                    .SingleOrDefault();

            TenantModel tenantToRemove = userToUpdate.Tenants.Single();

            userToUpdate.Tenants.Remove(tenantToRemove);

            subject.SaveChanges();

            Assert.AreEqual(1, tenantToRemove.Users.Count);
        }
        public void UpdateAssoicatedCollection_AddNewEntity_SlaveSide_ValidateOtherEntityIsUpdated()
        {
            var bulkUpdaterMock = new BulkUpdaterMock();

            bulkUpdaterMock.AddMockResponse(new BulkResponseRow("1", "2-123-Updated", null, null));

            var couchDBClientMock = new CouchDBClientAdapterMock(RawResponseWithOneTenant, bulkUpdaterMock);
            var subject           = ContextTestHelper.BuildContextForTest(couchDBClientMock);
            var userToUpdate      = subject.View <UserModel>("fake_not_used")
                                    .AssociatedCollection(x => x.Tenants, 1)
                                    .SingleOrDefault();

            TenantModel newTenant = new TenantModel
            {
                TenantModelID = "2001",
                Name          = "Tin-Tenant",
                Users         = new HashSet <UserModel>()
            };

            subject.Update(newTenant);
            userToUpdate.Tenants.Add(newTenant);

            CouchPotatoAssert.ModifiedDocumentsCount(subject, 1, "Only the new tenant document should be updated (created)");
        }