示例#1
0
        public void Should_DeleteOrgsAndPreferences()
        {
            var models = CreateDataContext().AddOrgs();

            CreateDataContext().AddOrgPreferences();

            Assert.True(CreateDataContext()
                        .Preferences
                        .ToList()
                        .Count == models.Count);

            foreach (var o in models)
            {
                Assert.False(GetRepo <OrgRepository>()
                             .ForActiveOrg(o.Id)
                             .Delete(o.Id, true)
                             .HasError);

                var prefCount = CreateDataContext()
                                .Preferences
                                .ToList()
                                .Count;

                var orgCount = CreateDataContext()
                               .Orgs
                               .ToList()
                               .Count;

                Assert.True(prefCount == orgCount);

                var model = GetRepo <OrgRepository>()
                            .ForActiveOrg(o.Id)
                            .GetPreferences();

                Assert.False(model.HasError);

                var emptyModel = new ModelPreference()
                {
                    OrgId = o.Id
                };
                Assert.True(emptyModel.Equals(model.Value));
            }

            Assert.Empty(CreateDataContext()
                         .Preferences
                         .ToList());
        }
示例#2
0
        public void ShouldNot_UpdatePreferencesWhenBadOrgId()
        {
            var models = CreateDataContext().AddOrgs();

            foreach (var m in models)
            {
                var prefRes = GetRepo <OrgRepository>()
                              .ForActiveOrg(m.Id)
                              .GetPreferences();

                Assert.False(prefRes.HasError);

                var model      = prefRes.Value;
                var emptyModel = new ModelPreference()
                {
                    OrgId = m.Id
                };
                Assert.True(emptyModel.Equals(prefRes.Value));

                TestFactory.Update(model);

                var res = GetRepo <OrgRepository>()
                          .ForActiveOrg(0)
                          .UpdatePreferences(model);

                Assert.False(res.HasError);
                Assert.True(res.Value.Equals(model));

                model.OrgId = TestFactory.GetRandomUShort(1000) + 1000;

                res = GetRepo <OrgRepository>()
                      .ForActiveOrg(m.Id)
                      .UpdatePreferences(model);

                Assert.False(res.HasError);
                Assert.True(res.Value.Equals(model));
            }
        }
示例#3
0
        public void Should_UpdatePreferences()
        {
            var models = CreateDataContext().AddOrgs();

            foreach (var o in models)
            {
                var prefRes = GetRepo <OrgRepository>()
                              .ForActiveOrg(o.Id)
                              .GetPreferences();

                Assert.False(prefRes.HasError);

                var model      = prefRes.Value;
                var emptyModel = new ModelPreference()
                {
                    OrgId = o.Id
                };
                Assert.True(emptyModel.Equals(prefRes.Value));

                TestFactory.Update(model);
                model.OrgId = o.Id;

                Assert.False(GetRepo <OrgRepository>()
                             .ForActiveOrg(o.Id)
                             .UpdatePreferences(model)
                             .HasError);

                prefRes = GetRepo <OrgRepository>()
                          .ForActiveOrg(o.Id)
                          .GetPreferences();

                Assert.False(prefRes.HasError);

                Assert.True(model.Equals(prefRes.Value));
            }
        }