Exemplo n.º 1
0
        public void Insert()
        {
            ImpressioDbContext.Instance.Customers.Load();

              if (ImpressioDbContext.Instance.Customers.Local.Count == 0)
              {
            var c = new Customer
              {
            Name = "c",
              };
            ImpressioDbContext.Instance.Customers.Add(c);
            ImpressioDbContext.Instance.SaveChanges();
              }

              var a = new Booking
            {
              Customer = ImpressioDbContext.Instance.Customers.First(),
              Name = "Booking",
              TimestampCreated = DateTime.Now,
              TimestampEdited = DateTime.Now,
            };
              ImpressioDbContext.Instance.Bookings.Add(a);
              ImpressioDbContext.Instance.SaveChanges();
              Assert.IsNotNull(a.BookingId);

              var ap = new BookingPosition
            {
              Name = "BookingPos",
              Booking = a,
            };
              ImpressioDbContext.Instance.BookingsPositions.Add(ap);
              ImpressioDbContext.Instance.SaveChanges();
              Assert.IsNotNull(ap.FkBooking);
              Assert.IsNotNull(ap.Booking);
              Assert.IsNotNull(a.BookingPositions);

              var des = new Description
            {
              BookingPosition = ap,
              Title = "Description",
            };
              ImpressioDbContext.Instance.Descriptions.Add(des);
              ImpressioDbContext.Instance.SaveChanges();
              Assert.IsNotNull(des.DescriptionId);
              Assert.IsNotNull(ap.Description);

              var desPos = new DescriptionPostion
            {
              Title = "Title",
              Content = "Content",
              Description = des,
            };
              ImpressioDbContext.Instance.DescriptionPositions.Add(desPos);
              ImpressioDbContext.Instance.SaveChanges();
              Assert.IsNotNull(desPos.DescriptionPositionId);
              Assert.IsNotNull(desPos.FkDescription);
              Assert.IsNotNull(des.DescriptionPostions);
        }
Exemplo n.º 2
0
        public void Insert()
        {
            var c = new Customer
            {
              Name = "Testcustomer",
              Remark = "Remarks",
            };
              ImpressioDbContext.Instance.Customers.Add(c);
              ImpressioDbContext.Instance.SaveChanges();
              Assert.IsNotNull(c.CustomerId);

              var a = new Address
            {
              Street = "Strasse",
              StreetNumber = "12b",
              City = "City",
              ZipCode = "4300",
            };
              c.Addresses = new List<Address> {a};
              ImpressioDbContext.Instance.SaveChanges();
              Assert.IsNotNull(a.AddressId);
              Assert.IsNotNull(c.Addresses);
              Assert.IsNotNull(a.FkCustomer);

              var p = new Person
            {
              Address = a,
              Lastname = "Lastname",
            };
              c.Persons = new List<Person>{p};
              ImpressioDbContext.Instance.SaveChanges();
              Assert.IsNotNull(c.Persons);
              Assert.IsNotNull(p.PersonId);
              Assert.IsNotNull(p.FkCustomer);
              Assert.IsNotNull(p.FkAddress);
        }