Example #1
0
        public void ThatSubstanceFactoryCreatesSubstanceWithGroup()
        {
            var dto  = SubstanceTestFixtures.GetSubstanceWithGroup();
            var fact = new SubstanceFactory(dto);

            Assert.IsNotNull(fact.Get().SubstanceGroup);
        }
Example #2
0
        public void ThatSubstanceCanBeFound()
        {
            var substance = SubstanceServices.WithDto(SubstanceTestFixtures.GetSubstanceWithGroup()).Get();

            Assert.AreEqual(substance,
                            SubstanceServices.Substances.Single(x => x.Name == substance.Name));
        }
Example #3
0
        public void ThatSubstanceCreatedWithSubstanceGroupContainsThatSubstance()
        {
            var dto   = SubstanceTestFixtures.GetSubstanceWithGroup();
            var fact  = new SubstanceFactory(dto);
            var subst = fact.Get();

            Assert.IsNotNull(subst.SubstanceGroup.Substances.First() == subst);
        }
Example #4
0
        public void ThatSubstanceWithSubstanceGroupIsBidirectional()
        {
            var substance = SubstanceServices.WithDto(SubstanceTestFixtures.GetSubstanceWithGroup()).Get();

            Assert.AreEqual(substance,
                            SubstanceServices.Substances.Single(x => x.Name == substance.Name)
                            .SubstanceGroup.Substances.Single(s => s.Name == substance.Name));
        }
Example #5
0
        private static Substance CreateSubstanceWithGroup()
        {
            var group = SubstanceGroup.Create(new SubstanceGroupDto {
                Name = "analgetica"
            });
            var subst = Substance.Create(SubstanceTestFixtures.GetSubstanceWithGroup());

            group.AddSubstance(subst);
            return(subst);
        }
Example #6
0
        public void ThatWhenSubstanceIsRemovedFromGroupAssociationsAreRemoved()
        {
            var dto   = SubstanceTestFixtures.GetSubstanceWithGroup();
            var fact  = new SubstanceFactory(dto);
            var subst = fact.Get();

            Assert.AreEqual(subst, subst.SubstanceGroup.Substances.First());
            subst.RemoveFromSubstanceGroup();
            Assert.IsNull(subst.SubstanceGroup);
        }
Example #7
0
        public void ThatSubstanceCanBeDeletedWithoutDeletingSubstanceGroup()
        {
            var substance = SubstanceServices.WithDto(SubstanceTestFixtures.GetSubstanceWithGroup()).Get();
            var id        = substance.SubstanceGroup.Id;

            SubstanceServices.Delete(substance);
            var group = Context.CurrentSession().Get <SubstanceGroup>(id);

            Assert.IsNotNull(group);
        }
        public void ThatSubstanceCanBeAdded()
        {
            var subst = Substance.Create(SubstanceTestFixtures.GetSubstanceWithGroup());
            var repos = new SubstanceRepository(GenFormApplication.SessionFactory)
            {
                subst
            };

            Assert.IsTrue(repos.Contains(subst));
        }
        private Substance GetSubstanceWithGroup()
        {
            var dto   = SubstanceTestFixtures.GetSubstanceWithGroup();
            var subst = Substance.Create(dto);
            var group = SubstanceGroup.Create(new SubstanceGroupDto {
                Name = dto.SubstanceGroupName
            });

            group.AddSubstance(subst);
            return(subst);
        }
Example #10
0
        public void ThatSubstanceCanBeDeletedWithinTransaction()
        {
            var substance = SubstanceServices.WithDto(SubstanceTestFixtures.GetSubstanceWithGroup()).Get();

            SubstanceServices.Delete(substance);

            substance =
                SubstanceServices.Substances.SingleOrDefault(
                    s => s.Name == SubstanceTestFixtures.GetSubstanceWithGroup().Name);
            Assert.IsNull(substance);
        }
Example #11
0
        public void ThatWhenSubstanceWithGroupIsPersistedSubstanceGroupContainsSubstance()
        {
            var dto   = SubstanceTestFixtures.GetSubstanceWithGroup();
            var fact  = new SubstanceFactory(dto);
            var subst = fact.Get();

            Assert.IsTrue(subst.SubstanceGroup.Substances.Contains(subst));
            Context.CurrentSession().Transaction.Commit();
            Context.CurrentSession().Transaction.Begin();

            Assert.IsTrue(subst.SubstanceGroup.Substances.Contains(subst));
        }
Example #12
0
        public void ThatSubstanceCanChangeName()
        {
            var substance = SubstanceServices.WithDto(SubstanceTestFixtures.GetSubstanceWithGroup()).Get();

            SubstanceServices.ChangeSubstanceName(substance, "dopamine changed");
            Context.CurrentSession().Transaction.Commit();

            Context.CurrentSession().Transaction.Begin();
            substance = SubstanceServices.Substances.First(s => s.Name == "dopamine changed");
            Assert.IsNotNull(substance);
            Assert.AreEqual(substance.Name, "dopamine changed");
        }
Example #13
0
        public void ThatSubstanceGroupCanBeDeletedWithoutDeletingSubstance()
        {
            var substance = (ISubstance)SubstanceServices.WithDto(SubstanceTestFixtures.GetSubstanceWithGroup()).Get();
            var group     = substance.SubstanceGroup;
            var id        = group.Id;

            ((SubstanceGroup)group).ClearAllSubstances();

            Assert.IsNull(substance.SubstanceGroup);
            Context.CurrentSession().Delete(group);
            group = Context.CurrentSession().Get <SubstanceGroup>(id);
            Assert.IsNull(group);
        }
Example #14
0
        public void ThatSubstanceCanBeDeleted()
        {
            var substance = SubstanceServices.WithDto(SubstanceTestFixtures.GetSubstanceWithGroup()).Get();

            SubstanceServices.Delete(substance);
            Context.CurrentSession().Transaction.Commit();

            Context.CurrentSession().Transaction.Begin();
            substance =
                SubstanceServices.Substances.SingleOrDefault(
                    s => s.Name == SubstanceTestFixtures.GetSubstanceWithGroup().Name);
            Assert.IsNull(substance);
        }
Example #15
0
        public void ThatSubstanceCanBeGet()
        {
            var substance = SubstanceServices.WithDto(SubstanceTestFixtures.GetSubstanceWithGroup()).Get();

            Assert.IsInstanceOfType(substance, typeof(Substance));
        }
Example #16
0
        public void ThatIfSubstanceDeleteIsCalledSubstanceGroupHasNoAssociationWithSubstance()
        {
            var substance = SubstanceServices.WithDto(SubstanceTestFixtures.GetSubstanceWithGroup()).Get();

            SubstanceServices.Delete(substance);
        }