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

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

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

            var firstTenant  = userToUpdate.Tenants.First();
            var secondTenant = userToUpdate.Tenants.Skip(1).First();

            // Clear and readd the first tenant
            userToUpdate.Tenants.Clear();
            userToUpdate.Tenants.Add(firstTenant);

            // Update the user even though it should have no effect
            subject.Update(userToUpdate);

            // TODO: it realy should be 1 because only TenantB is modified
            // by removing User 1 from it users array.
            int expectedModifiedDocuments = 3;

            CouchPotatoAssert.ModifiedDocumentsCount(subject, expectedModifiedDocuments, "Only the second tenant should be updated");
        }
예제 #2
0
        public void InsertTenantEntity_ValidateModifiedDocumentsCount()
        {
            var bulkUpdaterMock   = new BulkUpdaterMock();
            var couchDBClientMock = new CouchDBClientAdapterMock(null, bulkUpdaterMock);
            var subject           = ContextTestHelper.BuildContextForTest(couchDBClientMock);

            TenantModel newTenant = new TenantModel
            {
                TenantModelID = "2001",
                Name          = "Tin-Tenant"
            };

            subject.Update(newTenant);

            CouchPotatoAssert.ModifiedDocumentsCount(subject, 1);
        }
        public void UpdateAssoicatedCollection_ClearCollection_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 tenantToRemove = userToUpdate.Tenants.Single();

            userToUpdate.Tenants.Clear();

            CouchPotatoAssert.ModifiedDocumentsCount(subject, 1);
        }
        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)");
        }