Exemplo n.º 1
0
        public void CreateBestellingTest()
        {
            var bestelling = new Bestelling()
            {
                Klant = new Klant()
                {
                    AzureId = "TestUser"
                },
                Id          = 1,
                TotaalPrijs = 60,
                Producten   = new List <BestellingItem>()
                {
                    new BestellingItem()
                    {
                        Aantal  = 2,
                        Id      = 1,
                        Product = new Cursus()
                        {
                            Titel             = "dotNET cursus",
                            Type              = ".NET",
                            Prijs             = 15,
                            Categorie         = "Cursus",
                            IsBuyable         = true,
                            Beschrijving      = "Some example text some ...",
                            LangeBeschrijving = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
                            FotoURLCard       = "https://52bec9fb483231ac1c712343-jebebgcvzf.stackpathdns.com/wp-content/uploads/2016/05/dotnet.jpg"
                        }
                    },
                    new BestellingItem()
                    {
                        Aantal  = 1,
                        Id      = 2,
                        Product = new Traject()
                        {
                            Titel             = "dotNET cursus",
                            Type              = ".NET",
                            Prijs             = 30,
                            Categorie         = "Cursus",
                            IsBuyable         = true,
                            Beschrijving      = "Some example text some ...",
                            LangeBeschrijving = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
                            FotoURLCard       = "https://52bec9fb483231ac1c712343-jebebgcvzf.stackpathdns.com/wp-content/uploads/2016/05/dotnet.jpg"
                        }
                    }
                }
            };

            var mockSet = new Mock <DbSet <Bestelling> >();

            var mockContext = new Mock <DatabaseContext>();

            mockContext.Setup(m => m.Bestellingen).Returns(mockSet.Object);

            var repo = new BestellingRepository(mockContext.Object);
            var createdBestelling = repo.AddBestellingToCustomer(bestelling);

            // Assert
            mockSet.Verify(m => m.Add(It.IsAny <Bestelling>()), Times.Once);
            Assert.AreEqual(bestelling.TotaalPrijs, createdBestelling.TotaalPrijs);
            Assert.IsNotNull(createdBestelling);
            Assert.AreEqual(bestelling.Producten.Count(), createdBestelling.Producten.Count());
            Assert.AreEqual(bestelling.Producten, createdBestelling.Producten);
            Assert.AreEqual(bestelling.Klant.AzureId, createdBestelling.Klant.AzureId);
        }