Exemple #1
0
        public void Pantry_ToDomainModel_ShouldMapNullPantry()
        {
            DB.Pantry dbPantry = null;
            Pantry    pantry   = EntityMapper.ToDomainModel(dbPantry);

            pantry.Should().BeNull();
        }
Exemple #2
0
        public void Pantry_ToDatabaseModel_ShouldMapNullPantry()
        {
            Pantry pantry = null;

            DB.Pantry dbPantry = EntityMapper.ToDatabaseModel(pantry);
            dbPantry.Should().BeNull();
        }
Exemple #3
0
        public void Pantry_ToDomainModel_ShouldMapEmptyPantry()
        {
            var    dbPantry = new DB.Pantry();
            Pantry pantry;

            Action action = () => { EntityMapper.ToDomainModel(dbPantry); };

            action.Should().NotThrow <ArgumentNullException>("all class fields should be initialized");

            pantry = EntityMapper.ToDomainModel(dbPantry);
            pantry.Id.Should().Be(dbPantry.Id);
            pantry.Items.Should().BeNullOrEmpty();
        }
Exemple #4
0
        public void Pantry_ToDatabaseModel_ShouldMapNonEmptyPantry()
        {
            Pantry pantry = new Pantry
            {
                Id    = 123,
                Items = new List <PantryItem>
                {
                    new PantryItem
                    {
                        Id       = 1,
                        Quantity = new Quantity {
                            Amount = 1, Unit = "ml"
                        },
                        Item = new Item {
                            Id = 1, Name = "Water"
                        }
                    },
                    new PantryItem
                    {
                        Id       = 2,
                        Quantity = new Quantity {
                            Amount = 5, Unit = "g"
                        },
                        Item = new Item {
                            Id = 2, Name = "Juice"
                        }
                    }
                }
            };

            DB.Pantry dbPantry = EntityMapper.ToDatabaseModel(pantry);

            dbPantry.Should().NotBeNull();
            dbPantry.Id.Should().Be(123);
            dbPantry.Items.Should().NotBeNullOrEmpty();
            dbPantry.Items.Count.Should().Be(2);
            dbPantry.Items.TrueForAll(i => i != null).Should().BeTrue();
        }