public void AddSalesData_ThrowsException_WhenAnyClassifierIsNull()
 {
     using (var bc = new BusinessContext())
     {
         Assert.Throws <ArgumentNullException>(() =>
                                               bc.AddSalesData(new SalesData(DateTime.Now, 15200, null, new Type2_Classifiers(), new Type3_Classifiers(), new Type4_Classifiers())));
         Assert.Throws <ArgumentNullException>(() =>
                                               bc.AddSalesData(new SalesData(DateTime.Now, 1800, new Type1_Classifiers(), null, new Type3_Classifiers(), new Type4_Classifiers())));
         Assert.Throws <ArgumentNullException>(() =>
                                               bc.AddSalesData(new SalesData(DateTime.Now, 11900, new Type1_Classifiers(), new Type2_Classifiers(), null, new Type4_Classifiers())));
         Assert.Throws <ArgumentNullException>(() =>
                                               bc.AddSalesData(new SalesData(DateTime.Now, 12900, new Type1_Classifiers(), new Type2_Classifiers(), new Type3_Classifiers(), null)));
     }
 }
        public void UpdateSalesData_ChangedValuesAreApplied()
        {
            using (var bc = new BusinessContext())
            {
                //Arrange
                var shipDate  = DateTime.Now;
                var salesData = new SalesData(shipDate, 10000, new Type1_Classifiers(), new Type2_Classifiers(), new Type3_Classifiers(), new Type4_Classifiers());
                bc.AddSalesData(salesData);

                const string newType1ClassifierName = "type1_____ClassifierName",
                             newType2ClassifierName = "type2_____ClassifierName",
                             newType3ClassifierName = "type2_____ClassifierName",
                             newType4ClassifierName = "type2_____ClassifierName";

                salesData.Type1Classifier.Type1_ClassifierName = newType1ClassifierName;
                salesData.Type2Classifier.Type2_ClassifierName = newType2ClassifierName;
                salesData.Type3Classifier.Type3_ClassifierName = newType3ClassifierName;
                salesData.Type4Classifier.Type4_ClassifierName = newType4ClassifierName;
                //Act
                bc.UpdateSalesData(salesData);
                bc.DataContext.Entry(salesData).Reload();
                //Assert
                Assert.AreEqual(newType1ClassifierName, salesData.Type1Classifier.Type1_ClassifierName);
                Assert.AreEqual(newType2ClassifierName, salesData.Type2Classifier.Type2_ClassifierName);
                Assert.AreEqual(newType3ClassifierName, salesData.Type3Classifier.Type3_ClassifierName);
                Assert.AreEqual(newType4ClassifierName, salesData.Type4Classifier.Type4_ClassifierName);
            }
        }
        public void GetSalesDataItems_Return_ItemsCount()
        {
            using (var bc = new BusinessContext())
            {
                //Arrange
                int expectedCount = 5;
                for (int i = 0; i < 5; i++)
                {
                    var shipDate  = DateTime.Now;
                    var salesData = new SalesData(shipDate, 12000, new Type1_Classifiers(), new Type2_Classifiers(), new Type3_Classifiers(), new Type4_Classifiers());
                    bc.AddSalesData(salesData);
                }

                //Arrangec
                var data = bc.GetSalesDataItems();
                //Assert
                Assert.AreEqual(expectedCount, data.Count());
            }
        }
        public void AddSalesDataItems_Returns_Success()
        {
            using (var bc = new BusinessContext())
            {
                //Arrange
                AddClassifiers_Returns_Success();
                var expectedCount = 12;

                var type1ClassifiersItems = bc.DataContext.Type1ClassifiersItems.ToList();
                var type2ClassifiersItems = bc.DataContext.Type2ClassifiersItems.ToList();
                var type3ClassifiersItems = bc.DataContext.Type3ClassifiersItems.ToList();
                var type4ClassifiersItems = bc.DataContext.Type4ClassifiersItems.ToList();
                //Act
                bc.AddSalesData(new SalesData(new DateTime(2015, 7, 20), 1000, type1ClassifiersItems[1], type2ClassifiersItems[0],
                                              type3ClassifiersItems[1], type4ClassifiersItems[2]));
                bc.AddSalesData(new SalesData(new DateTime(2011, 5, 10), 900, type1ClassifiersItems[0], type2ClassifiersItems[1],
                                              type3ClassifiersItems[1], type4ClassifiersItems[0]));
                bc.AddSalesData(new SalesData(new DateTime(2009, 5, 10), 700, type1ClassifiersItems[1], type2ClassifiersItems[2],
                                              type3ClassifiersItems[0], type4ClassifiersItems[0]));
                bc.AddSalesData(new SalesData(new DateTime(2010, 6, 15), 1900, type1ClassifiersItems[1], type2ClassifiersItems[1],
                                              type3ClassifiersItems[2], type4ClassifiersItems[1]));
                bc.AddSalesData(new SalesData(new DateTime(2010, 5, 11), 22900, type1ClassifiersItems[2], type2ClassifiersItems[2],
                                              type3ClassifiersItems[2], type4ClassifiersItems[1]));
                bc.AddSalesData(new SalesData(new DateTime(2009, 7, 20), 11900, type1ClassifiersItems[2], type2ClassifiersItems[0],
                                              type3ClassifiersItems[1], type4ClassifiersItems[2]));
                bc.AddSalesData(new SalesData(new DateTime(2011, 7, 20), 18000, type1ClassifiersItems[1], type2ClassifiersItems[1],
                                              type3ClassifiersItems[1], type4ClassifiersItems[1]));
                bc.AddSalesData(new SalesData(new DateTime(2011, 7, 10), 15900, type1ClassifiersItems[0], type2ClassifiersItems[1],
                                              type3ClassifiersItems[2], type4ClassifiersItems[1]));
                bc.AddSalesData(new SalesData(new DateTime(2009, 5, 9), 12900, type1ClassifiersItems[2], type2ClassifiersItems[1],
                                              type3ClassifiersItems[0], type4ClassifiersItems[2]));
                bc.AddSalesData(new SalesData(new DateTime(2009, 5, 15), 12700, type1ClassifiersItems[0], type2ClassifiersItems[1],
                                              type3ClassifiersItems[1], type4ClassifiersItems[2]));
                bc.AddSalesData(new SalesData(new DateTime(2010, 6, 18), 11900, type1ClassifiersItems[1], type2ClassifiersItems[1],
                                              type3ClassifiersItems[2], type4ClassifiersItems[1]));
                bc.AddSalesData(new SalesData(new DateTime(2009, 7, 20), 15900, type1ClassifiersItems[2], type2ClassifiersItems[2],
                                              type3ClassifiersItems[0], type4ClassifiersItems[0]));
                //Assert
                Assert.AreEqual(expectedCount, bc.DataContext.SalesStatisticItems.Count());
            }
        }
 public async Task <SalesData> CreateItem(SalesData data)
 {
     return(await Task.Run(() => { return _context.AddSalesData(data); }));
 }