public void Test_Getters_And_Setters() { List<Orderline> orderlines = new List<Orderline>(); Orderline OL1= new Orderline() {OrderId = 2, MovieId = 6, Amount = 6, Price = 30}; Orderline Ol2= new Orderline() {OrderId = 2, MovieId = 17, Amount = 8, Price = 30}; orderlines.Add(Ol2); orderlines.Add(OL1); Customer cust = new Customer() { Id = 1, FirstName = "Someone", MiddleName = "Else", LastName = "Name", Email = "*****@*****.**", StreetName = "Bla Vej", StreetNumber = 1, Password = "******" }; Status stat = new Status() { Id = 1, Name = "Shipped" }; Order Ord = new Order() {Id=1,Orderlines = orderlines, Customer = cust, OrderDate = DateTime.Now.Date, Status = stat}; Ord.Id = 1; Ord.Orderlines = orderlines; Ord.Customer = cust; Ord.OrderDate=DateTime.Now.Date; Ord.Status = stat; Assert.AreEqual(Ord.Id,1); Assert.AreEqual(Ord.Orderlines,orderlines); Assert.AreEqual(Ord.Customer,cust); Assert.AreEqual(Ord.OrderDate, DateTime.Now.Date); Assert.AreEqual(Ord.Status,stat); }
public void Test_Constructor() { List<Orderline> orderlines = new List<Orderline>(); Orderline OL1 = new Orderline() { OrderId = 2, MovieId = 6, Amount = 6, Price = 30 }; Orderline Ol2 = new Orderline() { OrderId = 2, MovieId = 17, Amount = 8, Price = 30 }; orderlines.Add(Ol2); orderlines.Add(OL1); Customer cust = new Customer() { Id = 1, FirstName = "Someone", MiddleName = "Else", LastName = "Name", Email = "*****@*****.**", StreetName = "Bla Vej", StreetNumber = 1, Password = "******" }; Order Ord = new Order(orderlines, cust); Assert.NotNull(Ord); Assert.NotNull(orderlines); Assert.NotNull(cust); }
public void Test_Add_ShoppingCart() { ShoppingCart cart = new ShoppingCart(); Orderline OL = new Orderline(); Movie mov = new Movie() { Id = 1, Title = "Avengers: Age Of Ultron", Genre = new Genre() { Id = 2, Name = "Action" }, Price = 150, Year = DateTime.Now, ImgUrl = "http://scaled.ysimag.es/movie/the-avengers-age-of-ultron", TrailerUrl = "https://www.youtube.com/watch?v=S2HIda5wSVU" }; Customer cust = new Customer() { Id = 1, FirstName = "Someone", MiddleName = "Else", LastName = "Name", Email = "*****@*****.**", StreetName = "Bla Vej", StreetNumber = 1, Password = "******" }; OL.Movie = mov; OL.Amount = 3; cust.Id = 1; cart.CustomerId = 1; cart.Orderline.Add(OL); Assert.AreEqual(cart.CustomerId,1); Assert.AreEqual(cust.Id, 1); Assert.AreEqual(cart.Orderline.First(), OL, "The movies should be equal"); }
public void Test_Getters_And_Setters() { Customer cust = new Customer() { Id = 1, FirstName = "Someone", MiddleName = "Else", LastName = "Name", Email = "*****@*****.**", StreetName = "Bla Vej", StreetNumber = 1, Password = "******" }; cust.Id = 1; cust.FirstName = "Someone"; cust.MiddleName = "Else"; cust.LastName = "Name"; cust.Email = "*****@*****.**"; cust.StreetName = "Bla Vej"; cust.StreetNumber = 1; cust.Password = "******"; Assert.AreEqual(cust.Id, 1); Assert.AreEqual(cust.FirstName, "Someone"); Assert.AreEqual(cust.MiddleName, "Else"); Assert.AreEqual(cust.LastName, "Name"); Assert.AreEqual(cust.Email, "*****@*****.**"); Assert.AreEqual(cust.StreetName, "Bla Vej"); Assert.AreEqual(cust.StreetNumber, 1); Assert.AreEqual(cust.Password, "111100"); Assert.AreEqual(cust.ToString(), "Someone Name"); }
public void Add(Customer cust) { using(var ctx = new MovieShopContext()) { ctx.Customers.Add(cust); ctx.SaveChanges(); } }
/// <summary> /// sends a cutomer that will then be added to the database. /// </summary> /// <param name="item">the customer to be added</param> /// <returns>the customer with the correct primary key.</returns> public override Customer Add(Customer item) { using (var httpClient = new HttpClient()) { var result = httpClient.PostAsJsonAsync(CUSTOMER_END_POINT, item).Result; return JsonConvert.DeserializeObject<Customer>(result.Content.ReadAsStringAsync().Result); } }
public void Test_ModelBinding() { Customer cust = new Customer() { Id = 1, FirstName = "Someone", MiddleName = "Else", LastName = "Name", Email = "*****@*****.**", StreetName = "Bla Vej", StreetNumber = -1, Password = "******" }; cust.StreetNumber = -1; Assert.AreEqual(cust.StreetNumber, -1); }