Example #1
0
        public void ThatUnitCollectionContainsUnit()
        {
            var unit  = UnitServices.WithDto((UnitTestFixtures.GetTestUnitMilligram())).Get();
            var group = unit.UnitGroup;

            Assert.IsTrue(group.Units.Contains(unit));
        }
        public void BeAbleToFindUnitInUnitGroup()
        {
            PersistUnit(Context.CurrentSession());
            var unit =
                Context.CurrentSession().Query <Unit>().Single(
                    x => x.Name == UnitTestFixtures.GetTestUnitMilligram().Name);

            Assert.IsTrue(unit.UnitGroup.Units.Contains(unit));
        }
        public void ThatUnitWithNoMultiplierCannotBeConstructed()
        {
            var group = UnitGroupTestFixtures.CreateUnitGroupMass();
            var dto   = UnitTestFixtures.GetTestUnitMilligram();

            dto.Multiplier = 0;

            AssertCreateFails(group, dto);
        }
        public void ThatUnitWithNoAbbreviationCannotBeConstructed()
        {
            var group = UnitGroupTestFixtures.CreateUnitGroupMass();
            var dto   = UnitTestFixtures.GetTestUnitMilligram();

            dto.Abbreviation = string.Empty;

            AssertCreateFails(group, dto);
        }
        public ActionResult GetUnits()
        {
            var units = new List <UnitDto>
            {
                UnitTestFixtures.GetTestUnitMililiter(),
                UnitTestFixtures.GetTestUnitMilligram()
            };

            return(this.Direct(new { success = true, data = units }));
        }
        private static Unit CreateUnit()
        {
            var group =
                UnitGroup.Create(new UnitGroupDto
            {
                Name            = UnitTestFixtures.GetTestUnitMilligram().UnitGroupName,
                AllowConversion = UnitTestFixtures.GetTestUnitMilligram().AllowConversion
            });
            var unit = Unit.Create(UnitTestFixtures.GetTestUnitMilligram(), group);

            return(unit);
        }
        public void NotAcceptTheDifferentUnitWithSameUnitNameTwice()
        {
            PersistUnit(Context.CurrentSession());
            var unit =
                Context.CurrentSession().Query <Unit>().Single(
                    x => x.Name == UnitTestFixtures.GetTestUnitMilligram().Name);
            var group = unit.UnitGroup;

            try
            {
                group.AddUnit(CreateUnit());
            }
            catch (System.Exception e)
            {
                Assert.IsNotInstanceOfType(e, typeof(AssertFailedException));
            }
        }
Example #8
0
        public void CorrectlyMapAProduct()
        {
            var group = UnitGroup.Create(new UnitGroupDto {
                AllowConversion = true, Name = "massa"
            });

            new PersistenceSpecification <Product>(Context.CurrentSession(), new ProductComparer())
            .CheckProperty(x => x.Name, "dopamine Dynatra infusievloeistof 200 mg in 5 mL ampul")
            .CheckProperty(x => x.GenericName, "dopamine")
            .CheckReference(x => x.Brand, Brand.Create(new BrandDto {
                Name = "Dynatra"
            }))
            .CheckProperty(x => x.DisplayName, "dopamine Dynatra infusievloeistof 200 mg in 5 mL ampul")
            .CheckReference(x => x.Package, Package.Create(new PackageDto {
                Name = "ampul", Abbreviation = "amp"
            }))
            .CheckReference(x => x.Shape, Shape.Create(new ShapeDto {
                Name = "infusievloeistof"
            }))
            .CheckProperty(x => x.Quantity, UnitValue.Create(10, Unit.Create(UnitTestFixtures.GetTestUnitMilligram(), group)))

            .VerifyTheMappings();
        }
 private static void AssertUnitNameIsSet(IUnit unit)
 {
     Assert.AreEqual(UnitTestFixtures.GetTestUnitMilligram().Name, unit.Name);
 }
 private static void AssertUnitGroupName(IUnit unit)
 {
     Assert.AreEqual(UnitTestFixtures.GetTestUnitMilligram().UnitGroupName, unit.UnitGroup.Name);
 }
        public void ThatUnitWithEmptyGroupCannotBeConstructed()
        {
            var dto = UnitTestFixtures.GetTestUnitMilligram();

            AssertCreateFails(null, dto);
        }