public void ShouldRecalculateFirmHavingTerritory()
        {
            SourceDb.Has(new Facts::Firm {
                Id = 1
            })
            .Has(new Facts::FirmAddress {
                FirmId = 1, TerritoryId = 2
            });

            TargetDb.Has(new CI::Firm {
                Id = 1
            })
            .Has(new CI::FirmTerritory {
                FirmId = 1, TerritoryId = 3
            });

            Transformation.Create(Query)
            .Recalculate <CI::Firm>(1)
            .Verify <CI::FirmTerritory>(m => m.Add(It.Is(Predicate.Match(new CI::FirmTerritory {
                FirmId = 1, TerritoryId = 2
            }))))
            .Verify <CI::FirmTerritory>(m => m.Delete(It.Is(Predicate.Match(new CI::FirmTerritory {
                FirmId = 1, TerritoryId = 3
            }))));
        }
        public void ShouldRecalculateFirmHavingClient()
        {
            SourceDb.Has(new Facts::Category {
                Id = 1, Level = 3
            })
            .Has(new Facts::Project {
                OrganizationUnitId = 1
            })
            .Has(new Facts::Client {
                Id = 1
            })
            .Has(new Facts::Firm {
                Id = 1, ClientId = 1, OrganizationUnitId = 1
            });

            TargetDb.Has(new CI::Firm {
                Id = 1
            })
            .Has(new CI::Client {
                Id = 1
            });

            Transformation.Create(Query)
            .Recalculate <CI::Firm>(1)
            .Verify <CI::Firm>(m => m.Update(It.Is(Predicate.Match(new CI::Firm {
                Id = 1, ClientId = 1
            }))))
            .Verify <CI::Client>(m => m.Update(It.Is(Predicate.Match(new CI::Client {
                Id = 1
            }))), Times.Never);
        }
        public void ShouldInitializeFirmHavingBalance()
        {
            SourceDb.Has(new Facts::Project {
                Id = 1, OrganizationUnitId = 1
            })

            .Has(new Facts::Client {
                Id = 1
            })
            .Has(new Facts::BranchOfficeOrganizationUnit {
                Id = 1, OrganizationUnitId = 1
            })
            .Has(new Facts::LegalPerson {
                Id = 1, ClientId = 1
            })
            .Has(new Facts::Account {
                Id = 1, LegalPersonId = 1, BranchOfficeOrganizationUnitId = 1, Balance = 123.45m
            })
            .Has(new Facts::Firm {
                Id = 1, ClientId = 1, OrganizationUnitId = 1
            });

            Transformation.Create(Query)
            .Initialize <CI::Firm>(1)
            .Verify <CI::Firm>(m => m.Add(It.Is(Predicate.Match(new CI::Firm {
                Id = 1, ProjectId = 1, ClientId = 1
            }))))
            .Verify <CI::FirmBalance>(m => m.Add(It.Is(Predicate.Match(new CI::FirmBalance {
                ProjectId = 1, FirmId = 1, AccountId = 1, Balance = 123.45m
            }))));
        }
        public void ShouldTransformFirmContact()
        {
            const long NotNull = 123;

            SourceDb.Has(
                new Erm::FirmContact {
                Id = 1, ContactType = 1, FirmAddressId = NotNull
            },
                new Erm::FirmContact {
                Id = 2, ContactType = 1, FirmAddressId = null
            },
                new Erm::FirmContact {
                Id = 3, ContactType = 2, FirmAddressId = NotNull
            },
                new Erm::FirmContact {
                Id = 4, ContactType = 4, FirmAddressId = NotNull
            });

            Transformation.Create(Query)
            .VerifyTransform(x => Specs.Map.Erm.ToFacts.FirmContacts.Map(x).ById(1), new Facts::FirmContact {
                Id = 1, HasPhone = true, FirmAddressId = NotNull
            })
            .VerifyTransform(x => Specs.Map.Erm.ToFacts.FirmContacts.Map(x).ById(2), Enumerable.Empty <Facts::FirmContact>())
            .VerifyTransform(x => Specs.Map.Erm.ToFacts.FirmContacts.Map(x).ById(3), Enumerable.Empty <Facts::FirmContact>())
            .VerifyTransform(x => Specs.Map.Erm.ToFacts.FirmContacts.Map(x).ById(4), new Facts::FirmContact {
                Id = 4, HasWebsite = true, FirmAddressId = NotNull
            });
        }
        public void ShouldDestroyFirmHavingCategory()
        {
            TargetDb.Has(new CI::Firm {
                Id = 1
            })
            .Has(new CI::FirmCategory1 {
                FirmId = 1, CategoryId = 1
            })
            .Has(new CI::FirmCategory2 {
                FirmId = 1, CategoryId = 2
            })
            ;

            Transformation.Create(Query)
            .Destroy <CI::Firm>(1)
            .Verify <CI::Firm>(m => m.Delete(It.Is(Predicate.Match(new CI::Firm {
                Id = 1
            }))))
            .Verify <CI::FirmCategory1>(m => m.Delete(It.Is(Predicate.Match(new CI::FirmCategory1 {
                FirmId = 1, CategoryId = 1
            }))))
            .Verify <CI::FirmCategory2>(m => m.Delete(It.Is(Predicate.Match(new CI::FirmCategory2 {
                FirmId = 1, CategoryId = 2
            }))))
            ;
        }
        public void ShouldRecalculateClientAndFirmIfCategoryFirmAddressUpdated()
        {
            SourceDb.Has(new Erm::CategoryFirmAddress {
                Id = 1, FirmAddressId = 1, CategoryId = 1
            })
            .Has(new Erm::FirmAddress {
                Id = 1, FirmId = 1
            })
            .Has(new Erm::Firm {
                Id = 1, OrganizationUnitId = 1, ClientId = 1
            })
            .Has(new Erm::Client {
                Id = 1
            });

            TargetDb.Has(new Facts::CategoryFirmAddress {
                Id = 1, FirmAddressId = 1, CategoryId = 1
            });
            TargetDb.Has(new Facts::FirmAddress {
                Id = 1, FirmId = 1
            });
            TargetDb.Has(new Facts::Firm {
                Id = 1, OrganizationUnitId = 1, ClientId = 1
            });
            TargetDb.Has(new Facts::Client {
                Id = 1
            });

            Transformation.Create(Query, RepositoryFactory)
            .ApplyChanges <Facts::CategoryFirmAddress>(1)
            .VerifyDistinct(Aggregate.Recalculate <CI::Firm>(1),
                            Aggregate.Recalculate <CI::Client>(1));
        }
示例#7
0
        public void ShouldRecalculateDependentAggregatesIfProjectUpdated()
        {
            SourceDb.Has(new Erm::Project {
                Id = 1, OrganizationUnitId = 2
            });

            TargetDb.Has(new Facts::Project {
                Id = 1, OrganizationUnitId = 1
            })
            .Has(new Facts::Territory {
                Id = 1, OrganizationUnitId = 1
            })
            .Has(new Facts::Territory {
                Id = 2, OrganizationUnitId = 2
            })
            .Has(new Facts::Firm {
                Id = 1, OrganizationUnitId = 1
            })
            .Has(new Facts::Firm {
                Id = 2, OrganizationUnitId = 2
            });

            Transformation.Create(Query, RepositoryFactory)
            .ApplyChanges <Facts::Project>(1)
            .VerifyDistinct(Statistics.Operation(1),
                            Aggregate.Recalculate <CI::Territory>(1),
                            Aggregate.Recalculate <CI::Firm>(1),
                            Aggregate.Recalculate <CI::Project>(1),
                            Aggregate.Recalculate <CI::Territory>(2),
                            Aggregate.Recalculate <CI::Firm>(2));
        }
示例#8
0
        public void ShouldRecalculateFirmIfContactUpdated()
        {
            SourceDb.Has(new Erm::Contact {
                Id = 1, ClientId = 2
            });

            TargetDb.Has(new Facts::Client {
                Id = 1
            })
            .Has(new Facts::Client {
                Id = 2
            })
            .Has(new Facts::Firm {
                Id = 1, ClientId = 1
            })
            .Has(new Facts::Firm {
                Id = 2, ClientId = 2
            })
            .Has(new Facts::Contact {
                Id = 1, ClientId = 1
            });

            Transformation.Create(Query, RepositoryFactory)
            .ApplyChanges <Facts::Contact>(1)
            .VerifyDistinct(Aggregate.Recalculate <CI.Client>(1), Aggregate.Recalculate <CI.Firm>(1), Aggregate.Recalculate <CI.Client>(2), Aggregate.Recalculate <CI.Firm>(2));
        }
        public void ShouldRecalculateFirmHavingBalance()
        {
            SourceDb.Has(new Facts::Project { Id = 1, OrganizationUnitId = 1 })
                    .Has(new Facts::Client { Id = 1 },
                         new Facts::Client { Id = 2 })
                    .Has(new Facts::BranchOfficeOrganizationUnit { Id = 1, OrganizationUnitId = 1 })
                    .Has(new Facts::LegalPerson { Id = 1, ClientId = 1 },
                         new Facts::LegalPerson { Id = 2, ClientId = 2 })
                    .Has(new Facts::Account { Id = 1, LegalPersonId = 1, BranchOfficeOrganizationUnitId = 1, Balance = 123 },
                         new Facts::Account { Id = 2, LegalPersonId = 2, BranchOfficeOrganizationUnitId = 1, Balance = 456 })
                    .Has(new Facts::Firm { Id = 1, ClientId = 1, OrganizationUnitId = 1 },
                         new Facts::Firm { Id = 2, ClientId = 2, OrganizationUnitId = 1 },
                         new Facts::Firm { Id = 3, OrganizationUnitId = 1 });

            TargetDb.Has(new CI::Firm { Id = 1 },
                         new CI::Firm { Id = 2 },
                         new CI::Firm { Id = 3 })
                    .Has(new CI::FirmBalance { FirmId = 2, AccountId = 2, ProjectId = 1, Balance = 123 },
                         new CI::FirmBalance { FirmId = 3, ProjectId = 1, Balance = 123 });

            Transformation.Create(Query)
                          .Recalculate<CI::Firm>(1, 2, 3)
                          .Verify<CI::Firm>(m => m.Update(It.Is(Predicate.Match(new CI::Firm { Id = 1, ClientId = 1, ProjectId = 1 }))))
                          .Verify<CI::Firm>(m => m.Update(It.Is(Predicate.Match(new CI::Firm { Id = 2, ClientId = 2, ProjectId = 1 }))))
                          .Verify<CI::Firm>(m => m.Update(It.Is(Predicate.Match(new CI::Firm { Id = 3, ProjectId = 1 }))))
                          .Verify<CI::FirmBalance>(m => m.Add(It.Is(Predicate.Match(new CI::FirmBalance { FirmId = 1, AccountId = 1, ProjectId = 1, Balance = 123 }))))
                          .Verify<CI::FirmBalance>(m => m.Update(It.Is(Predicate.Match(new CI::FirmBalance { FirmId = 2, AccountId = 2, ProjectId = 1, Balance = 456 }))))
                          .Verify<CI::FirmBalance>(m => m.Delete(It.Is(Predicate.Match(new CI::FirmBalance { FirmId = 3, ProjectId = 1, Balance = 123 }))));
        }
示例#10
0
        public void ShouldRecalculateFirmIfCategoryOfLevel1Deleted()
        {
            TargetDb.Has(new Facts::Firm {
                Id = 1
            })
            .Has(new Facts::FirmAddress {
                Id = 1, FirmId = 1
            })
            .Has(new Facts::CategoryFirmAddress {
                Id = 1, FirmAddressId = 1, CategoryId = 3
            })
            .Has(new Facts::Category {
                Id = 1, Level = 1
            })
            .Has(new Facts::Category {
                Id = 2, Level = 2, ParentId = 1
            })
            .Has(new Facts::Category {
                Id = 3, Level = 3, ParentId = 2
            });

            Transformation.Create(Query, RepositoryFactory)
            .ApplyChanges <Facts::Category>(1)
            .VerifyDistinct(Aggregate.Recalculate <CI.Firm>(1));
        }
示例#11
0
        public void ShouldFillCategoriesWithoutStatisticsWithZeros()
        {
            SourceDb.Has(new Bit::FirmCategory {
                FirmId = 1, CategoryId = 1, ProjectId = 1
            });                                                                                // Фирма без статистики
            SourceDb.Has(new Bit::FirmCategory {
                FirmId = 2, CategoryId = 1, ProjectId = 1
            });                                                                                // Фирма со статистикой
            SourceDb.Has(new Bit::FirmCategoryStatistics {
                FirmId = 2, CategoryId = 1, ProjectId = 1, Hits = 100, Shows = 200
            });
            SourceDb.Has(new Bit::ProjectCategoryStatistics {
                ProjectId = 1, CategoryId = 1, AdvertisersCount = 1
            });

            Transformation.Create(Query)
            .VerifyTransform(
                x => Specs.Map.Facts.ToStatistics.FirmCategoryStatistics.Map(x),
                Inquire(
                    new Statistics::FirmCategoryStatistics {
                FirmId = 1, CategoryId = 1, ProjectId = 1, AdvertisersShare = 0.5f, FirmCount = 2, Hits = 0, Shows = 0
            },
                    new Statistics::FirmCategoryStatistics {
                FirmId = 2, CategoryId = 1, ProjectId = 1, AdvertisersShare = 0.5f, FirmCount = 2, Hits = 100, Shows = 200
            }));
        }
示例#12
0
        public void ShouldTransformFirmCategoryStatistics()
        {
            SourceDb.Has(new Bit::FirmCategory {
                FirmId = 1, CategoryId = 1, ProjectId = 1
            },
                         new Bit::FirmCategory {
                FirmId = 2, CategoryId = 1, ProjectId = 1
            },
                         new Bit::FirmCategory {
                FirmId = 2, CategoryId = 2, ProjectId = 1
            })
            .Has(new Bit::FirmCategoryStatistics {
                FirmId = 1, CategoryId = 1, ProjectId = 1, Hits = 10000, Shows = 20000
            })
            .Has(new Bit::ProjectCategoryStatistics {
                ProjectId = 1, CategoryId = 1, AdvertisersCount = 1
            });

            Transformation.Create(Query)
            .VerifyTransform(
                x => Specs.Map.Facts.ToStatistics.FirmCategoryStatistics.Map(x),
                Inquire(
                    new Statistics::FirmCategoryStatistics {
                FirmId = 1, CategoryId = 1, ProjectId = 1, AdvertisersShare = 0.5f, FirmCount = 2, Hits = 10000, Shows = 20000
            },
                    new Statistics::FirmCategoryStatistics {
                FirmId = 2, CategoryId = 1, ProjectId = 1, AdvertisersShare = 0.5f, FirmCount = 2, Hits = 0, Shows = 0
            },
                    new Statistics::FirmCategoryStatistics {
                FirmId = 2, CategoryId = 2, ProjectId = 1, AdvertisersShare = 0f, FirmCount = 1, Hits = 0, Shows = 0
            }));
        }
示例#13
0
        public void ShouldRecalculateFirmsIfActivityCreated()
        {
            SourceDb.Has(new Appointment {
                Id = 1, ModifiedOn = DateTimeOffset.Now, IsActive = true, Status = ActivityStatusCompleted
            })
            .Has(new AppointmentReference {
                ActivityId = 1, Reference = RegardingObjectReference, ReferencedObjectId = 2, ReferencedType = EntityTypeIds.Client
            },
                 new AppointmentReference {
                ActivityId = 1, Reference = RegardingObjectReference, ReferencedObjectId = 3, ReferencedType = EntityTypeIds.Firm
            });

            TargetDb.Has(new Facts::Client {
                Id = 2
            });
            TargetDb.Has(new Facts::Firm {
                Id = 3
            });
            TargetDb.Has(new Facts::Firm {
                Id = 4, ClientId = 2
            });
            TargetDb.Has(new Facts::Firm {
                Id = 5
            });

            Transformation.Create(Query, RepositoryFactory)
            .ApplyChanges <Facts::Activity>(1)
            .VerifyDistinct(Aggregate.Recalculate <CI::Firm>(3),
                            Aggregate.Recalculate <CI::Firm>(4));
        }
        public void ShouldTransformContact()
        {
            SourceDb.Has(
                new Erm::Contact {
                Id = 1, ClientId = 2
            },
                new Erm::Contact {
                Id = 2, Role = 200000
            },
                new Erm::Contact {
                Id = 3, Role = 200001
            },
                new Erm::Contact {
                Id = 4, Role = 200002
            },
                new Erm::Contact {
                Id = 5, MainPhoneNumber = "phone"
            },
                new Erm::Contact {
                Id = 6, MobilePhoneNumber = "phone"
            },
                new Erm::Contact {
                Id = 7, HomePhoneNumber = "phone"
            },
                new Erm::Contact {
                Id = 8, AdditionalPhoneNumber = "phone"
            },
                new Erm::Contact {
                Id = 9, Website = "site"
            });

            Transformation.Create(Query)
            .VerifyTransform(x => Specs.Map.Erm.ToFacts.Contacts.Map(x).ById(1), new Facts::Contact {
                Id = 1, ClientId = 2
            })
            .VerifyTransform(x => Specs.Map.Erm.ToFacts.Contacts.Map(x).ById(2), new Facts::Contact {
                Id = 2, Role = 1
            })
            .VerifyTransform(x => Specs.Map.Erm.ToFacts.Contacts.Map(x).ById(3), new Facts::Contact {
                Id = 3, Role = 2
            })
            .VerifyTransform(x => Specs.Map.Erm.ToFacts.Contacts.Map(x).ById(4), new Facts::Contact {
                Id = 4, Role = 3
            })
            .VerifyTransform(x => Specs.Map.Erm.ToFacts.Contacts.Map(x).ById(5), new Facts::Contact {
                Id = 5, HasPhone = true
            })
            .VerifyTransform(x => Specs.Map.Erm.ToFacts.Contacts.Map(x).ById(6), new Facts::Contact {
                Id = 6, HasPhone = true
            })
            .VerifyTransform(x => Specs.Map.Erm.ToFacts.Contacts.Map(x).ById(7), new Facts::Contact {
                Id = 7, HasPhone = true
            })
            .VerifyTransform(x => Specs.Map.Erm.ToFacts.Contacts.Map(x).ById(8), new Facts::Contact {
                Id = 8, HasPhone = true
            })
            .VerifyTransform(x => Specs.Map.Erm.ToFacts.Contacts.Map(x).ById(9), new Facts::Contact {
                Id = 9, HasWebsite = true
            });
        }
        public void ShouldRecalculateFirmHavingCategory()
        {
            SourceDb.Has(new Facts::Category { Id = 1, Level = 3 },
                         new Facts::Category { Id = 2, Level = 3 });
            SourceDb.Has(new Facts::CategoryOrganizationUnit { Id = 1, CategoryId = 1, OrganizationUnitId = 1 },
                         new Facts::CategoryOrganizationUnit { Id = 2, CategoryId = 2, OrganizationUnitId = 1 });
            SourceDb.Has(new Facts::Project { OrganizationUnitId = 1 });
            SourceDb.Has(new Facts::FirmAddress { Id = 1, FirmId = 1 },
                         new Facts::FirmAddress { Id = 2, FirmId = 2 });
            SourceDb.Has(new Facts::CategoryFirmAddress { Id = 1, FirmAddressId = 1, CategoryId = 1 },
                         new Facts::CategoryFirmAddress { Id = 2, FirmAddressId = 2, CategoryId = 2 });
            SourceDb.Has(new Facts::Firm { Id = 1, OrganizationUnitId = 1 },
                 new Facts::Firm { Id = 2, OrganizationUnitId = 1 },
                 new Facts::Firm { Id = 3, OrganizationUnitId = 1 });

            TargetDb.Has(new CI::Firm { Id = 1 },
                         new CI::Firm { Id = 2 },
                         new CI::Firm { Id = 3 })
                    .Has(new CI::FirmCategory { FirmId = 2, CategoryId = 1 },
                         new CI::FirmCategory { FirmId = 3, CategoryId = 1 });

            Transformation.Create(Query)
                          .Recalculate<CI::Firm>(1)
                          .Recalculate<CI::Firm>(2)
                          .Recalculate<CI::Firm>(3)
                          .Verify<CI::Firm>(m => m.Update(It.Is(Predicate.Match(new CI::Firm { Id = 1, AddressCount = 1 }))))
                          .Verify<CI::Firm>(m => m.Update(It.Is(Predicate.Match(new CI::Firm { Id = 2, AddressCount = 1 }))))
                          .Verify<CI::Firm>(m => m.Update(It.Is(Predicate.Match(new CI::Firm { Id = 3 }))))
                          .Verify<CI::FirmCategory>(m => m.Add(It.Is(Predicate.Match(new CI::FirmCategory { FirmId = 1, CategoryId = 1 }))))
                          .Verify<CI::FirmCategory>(m => m.Add(It.Is(Predicate.Match(new CI::FirmCategory { FirmId = 2, CategoryId = 2 }))))
                          .Verify<CI::FirmCategory>(m => m.Delete(It.Is(Predicate.Match(new CI::FirmCategory { FirmId = 2, CategoryId = 1 }))))
                          .Verify<CI::FirmCategory>(m => m.Delete(It.Is(Predicate.Match(new CI::FirmCategory { FirmId = 3, CategoryId = 1 }))));
        }
        public void AdvertisersShareShouldNotBeMoreThanOne()
        {
            SourceDb.Has(new Facts::Project {
                Id = 1
            })
            .Has(new Facts::Firm {
                Id = 1
            })
            .Has(new Facts::FirmAddress {
                Id = 1, FirmId = 1
            })
            .Has(new Facts::Category {
                Id = 1
            })
            .Has(new Facts::CategoryFirmAddress {
                FirmAddressId = 1, CategoryId = 1
            });

            SourceDb.Has(new Bit::FirmCategoryStatistics {
                FirmId = 1, CategoryId = 1, ProjectId = 1, Hits = 10000, Shows = 20000
            })
            .Has(new Bit::ProjectCategoryStatistics {
                ProjectId = 1, CategoryId = 1, AdvertisersCount = 5
            });

            Transformation.Create(Query)
            .VerifyTransform(
                x => Specs.Map.Facts.ToStatistics.FirmCategory3.Map(x),
                Inquire(new Statistics::FirmCategory3 {
                FirmId = 1, CategoryId = 1, ProjectId = 1, AdvertisersShare = 1f, FirmCount = 1, Hits = 10000, Shows = 20000
            }));
        }
示例#17
0
        public void ShouldRecalculateFirmIfBranchOfficeOrganizationUnitUpdated()
        {
            SourceDb.Has(new Erm::BranchOfficeOrganizationUnit {
                Id = 1, OrganizationUnitId = 2
            });

            TargetDb.Has(new Facts::Firm {
                Id = 1, ClientId = 1, OrganizationUnitId = 1
            })
            .Has(new Facts::Firm {
                Id = 2, ClientId = 1, OrganizationUnitId = 2
            })
            .Has(new Facts::Client {
                Id = 1
            })
            .Has(new Facts::BranchOfficeOrganizationUnit {
                Id = 1, OrganizationUnitId = 1
            })
            .Has(new Facts::LegalPerson {
                Id = 1, ClientId = 1
            })
            .Has(new Facts::Account {
                Id = 1, LegalPersonId = 1, BranchOfficeOrganizationUnitId = 1
            });

            Transformation.Create(Query, RepositoryFactory)
            .ApplyChanges <Facts::BranchOfficeOrganizationUnit>(1)
            .VerifyDistinct(Aggregate.Recalculate <CI.Firm>(1), Aggregate.Recalculate <CI.Firm>(2));
        }
        public void ShouldTransformFirmContactInfoFromFirm()
        {
            SourceDb.Has(new Facts::Project {
                Id = 1, OrganizationUnitId = 0
            })
            .Has(new Facts::Firm {
                Id = 1, Name = "has no addresses"
            },
                 new Facts::Firm {
                Id = 2, Name = "has addresses, but no contacts"
            },
                 new Facts::Firm {
                Id = 3, Name = "has one phone contact"
            },
                 new Facts::Firm {
                Id = 4, Name = "has one website contact"
            },
                 new Facts::Firm {
                Id = 5, Name = "has an unknown contact"
            })
            .Has(new Facts::FirmAddress {
                Id = 1, FirmId = 2
            },
                 new Facts::FirmAddress {
                Id = 2, FirmId = 3
            },
                 new Facts::FirmAddress {
                Id = 3, FirmId = 4
            },
                 new Facts::FirmAddress {
                Id = 4, FirmId = 5
            })
            .Has(new Facts::FirmContact {
                Id = 1, HasPhone = true, FirmAddressId = 2
            },
                 new Facts::FirmContact {
                Id = 2, HasWebsite = true, FirmAddressId = 3
            },
                 new Facts::FirmContact {
                Id = 3, FirmAddressId = 4
            });

            Transformation.Create(Query)
            .VerifyTransform(x => Specs.Map.Facts.ToCI.Firms.Map(x).ById(1), Inquire(new CI::Firm {
                HasPhone = false, HasWebsite = false
            }), x => new { x.HasPhone, x.HasWebsite })
            .VerifyTransform(x => Specs.Map.Facts.ToCI.Firms.Map(x).ById(2), Inquire(new CI::Firm {
                HasPhone = false, HasWebsite = false
            }), x => new { x.HasPhone, x.HasWebsite })
            .VerifyTransform(x => Specs.Map.Facts.ToCI.Firms.Map(x).ById(3), Inquire(new CI::Firm {
                HasPhone = true, HasWebsite = false
            }), x => new { x.HasPhone, x.HasWebsite })
            .VerifyTransform(x => Specs.Map.Facts.ToCI.Firms.Map(x).ById(4), Inquire(new CI::Firm {
                HasPhone = false, HasWebsite = true
            }), x => new { x.HasPhone, x.HasWebsite })
            .VerifyTransform(x => Specs.Map.Facts.ToCI.Firms.Map(x).ById(5), Inquire(new CI::Firm {
                HasPhone = false, HasWebsite = false
            }), x => new { x.HasPhone, x.HasWebsite });
        }
        public void ShouldDestroyClient()
        {
            TargetDb.Has(new CI::Client { Id = 1 });

            Transformation.Create(Query)
                          .Destroy<CI::Client>(1)
                          .Verify<CI::Client>(m => m.Delete(It.Is(Predicate.Match(new CI::Client { Id = 1 }))));
        }
        public void ShouldDestroyCategoryGroup()
        {
            TargetDb.Has(new CI::CategoryGroup { Id = 1 });

            Transformation.Create(Query)
                          .Destroy<CI::CategoryGroup>(1)
                          .Verify<CI::CategoryGroup>(x => x.Delete(It.Is(Predicate.Match(new CI::CategoryGroup { Id = 1 }))));
        }
        public void ShouldInitializeCategoryGroup()
        {
            SourceDb.Has(new Facts::CategoryGroup { Id = 1 });

            Transformation.Create(Query)
                          .Initialize<CI::CategoryGroup>(1)
                          .Verify<CI::CategoryGroup>(m => m.Add(It.Is(Predicate.Match(new CI::CategoryGroup { Id = 1 }))));
        }
        public void ShouldInitializeProject()
        {
            SourceDb.Has(new Facts::Project { Id = 1 });

            Transformation.Create(Query)
                          .Initialize<CI::Project>(1)
                          .Verify<CI::Project>(m => m.Add(It.Is(Predicate.Match(new CI::Project { Id = 1 }))));
        }
        public void ShouldInitializeTerritory()
        {
            SourceDb.Has(new Facts::Project { Id = 1, OrganizationUnitId = 1 })
                    .Has(new Facts::Territory { Id = 2, OrganizationUnitId = 1 });

            Transformation.Create(Query)
                          .Initialize<CI::Territory>(2)
                          .Verify<CI::Territory>(m => m.Add(It.Is(Predicate.Match(new CI::Territory { Id = 2, ProjectId = 1 }))));
        }
        public void ShouldRecalculateClient()
        {
            SourceDb.Has(new Facts::Client { Id = 1, Name = "new name" });
            TargetDb.Has(new CI::Client { Id = 1, Name = "old name" });

            Transformation.Create(Query)
                          .Recalculate<CI::Client>(1)
                          .Verify<CI::Client>(m => m.Update(It.Is(Predicate.Match(new CI::Client { Id = 1, Name = "new name" }))));
        }
        public void ShouldInitializeFirm()
        {
            SourceDb.Has(new Facts::Project { OrganizationUnitId = 1 })
                    .Has(new Facts::Firm { Id = 1, OrganizationUnitId = 1 });

            Transformation.Create(Query)
                          .Initialize<CI::Firm>(1)
                          .Verify<CI::Firm>(m => m.Add(It.Is(Predicate.Match(new CI::Firm { Id = 1 }))));
        }
        public void ShouldInitializeClientHavingContact()
        {
            SourceDb.Has(new Facts::Client { Id = 1 })
                    .Has(new Facts::Contact { Id = 1, ClientId = 1 });

            Transformation.Create(Query)
                          .Initialize<CI::Client>(1)
                          .Verify<CI::Client>(m => m.Add(It.Is(Predicate.Match(new CI::Client { Id = 1 }))))
                          .Verify<CI::ClientContact>(m => m.Add(It.Is(Predicate.Match(new CI::ClientContact { ClientId = 1, ContactId = 1 }))));
        }
示例#27
0
        public void ShouldInitializeClientIfClientCreated()
        {
            SourceDb.Has(new Erm::Client {
                Id = 1
            });

            Transformation.Create(Query, RepositoryFactory)
            .ApplyChanges <Facts::Client>(1)
            .VerifyDistinct(Aggregate.Initialize <CI.Client>(1));
        }
示例#28
0
        public void ShouldDestroyClientIfClientDeleted()
        {
            TargetDb.Has(new Facts::Client {
                Id = 1
            });

            Transformation.Create(Query, RepositoryFactory)
            .ApplyChanges <Facts::Client>(1)
            .VerifyDistinct(Aggregate.Destroy <CI.Client>(1));
        }
示例#29
0
        public void ShouldDestroyTerritoryIfTerritoryDeleted()
        {
            TargetDb.Has(new Facts::Territory {
                Id = 1, OrganizationUnitId = 2
            });

            Transformation.Create(Query, RepositoryFactory)
            .ApplyChanges <Facts::Territory>(1)
            .VerifyDistinct(Aggregate.Destroy <CI::Territory>(1));
        }
示例#30
0
        public void ShouldInitializeTerritoryIfTerritoryCreated()
        {
            SourceDb.Has(new Erm::Territory {
                Id = 1, OrganizationUnitId = 2
            });

            Transformation.Create(Query, RepositoryFactory)
            .ApplyChanges <Facts::Territory>(1)
            .VerifyDistinct(Aggregate.Initialize <CI::Territory>(1));
        }