Exemplo n.º 1
0
        public void AddSurvey_AddingSurveyWithPriceLessThan50PerAverageSurveyPrice_ShouldReturnSurveyCountAsOne()
        {
            //Arrange
            double itemPrice           = 100.0;
            string productName         = "ssd";
            string surveyName          = "x";
            double expectedSurveyCount = 1;
            Item   item = new Item(manager.GetPricingStrategy(supply, demand));

            //Act
            ItemSurvey itemsurvey1 = new ItemSurvey()
            {
                ItemName = productName, Price = itemPrice, SurveyName = surveyName
            };

            item.AddSurvey(itemsurvey1);
            ItemSurvey itemsurvey2 = new ItemSurvey()
            {
                ItemName = productName, Price = (itemPrice / 2 - 10), SurveyName = surveyName
            };

            item.AddSurvey(itemsurvey2);


            //Assert
            Assert.AreEqual(expectedSurveyCount, item.SurveyCount, "Should return single price for survey");
        }
Exemplo n.º 2
0
        public void AddSurvey_WhenOnlySingleSurvey_ShouldReturnSurveyCountAsOne()
        {
            //Arrange
            double itemPrice           = 100.0;
            string productName         = "ssd";
            string surveyName          = "x";
            double expectedSurveyCount = 1;
            Item   item = new Item(manager.GetPricingStrategy(supply, demand));
            //Act
            ItemSurvey itemsurvey = new ItemSurvey()
            {
                ItemName = productName, Price = itemPrice, SurveyName = surveyName
            };

            item.AddSurvey(itemsurvey);

            //Assert
            Assert.AreEqual(expectedSurveyCount, item.SurveyCount, "Should return single price for survey");
        }
Exemplo n.º 3
0
        public void ItemPrice_WhenOnlySingleSurvey_ShouldReturnSamePrice()
        {
            //Arrange
            double itemPrice   = 100.0;
            string productName = "ssd";
            string surveyName  = "x";
            double expected    = 100.0;

            //Act
            ItemSurvey itemsurvey = new ItemSurvey()
            {
                ItemName = productName, Price = itemPrice, SurveyName = surveyName
            };

            item.AddSurvey(itemsurvey);

            //Assert
            Assert.AreEqual(expected, item.Price, "Should return single price for survey");
        }
Exemplo n.º 4
0
        public void AddSurvey_When2eValidSurvey_ShouldReturnSurveyCountAs2()
        {
            //Arrange
            double itemPrice           = 100.0;
            string productName         = "ssd";
            string surveyName          = "x";
            double expectedSurveyCount = 2;

            //Act
            ItemSurvey itemsurvey1 = new ItemSurvey()
            {
                ItemName = productName, Price = itemPrice, SurveyName = surveyName
            };

            item.AddSurvey(itemsurvey1);
            ItemSurvey itemsurvey2 = new ItemSurvey()
            {
                ItemName = productName, Price = itemPrice + 1, SurveyName = surveyName
            };

            item.AddSurvey(itemsurvey2);
            //Assert
            Assert.AreEqual(expectedSurveyCount, item.SurveyCount, "Should return single price for survey");
        }
Exemplo n.º 5
0
        public void ItemPrice_WhenOnlyMultipleSurveyWithPriceLessThan50PerOfAveragePrice_ShouldNotConsiderPriceAsItsDiscountedPrice()
        {
            //Arrange
            List <double> surveyList = new List <double>()
            {
                10.0, 11, 12, 2
            };
            string productName = "ssd";

            double expectedSurveyCount = 3;

            //Act
            surveyList.ForEach(x =>
            {
                var itemsurvey = new ItemSurvey()
                {
                    ItemName = productName, Price = x, SurveyName = "xxx"
                };
                item.AddSurvey(itemsurvey);
            });

            //Assert
            Assert.AreEqual(expectedSurveyCount, item.SurveyCount, "Should not consider survey whose price less than 50% of average price as its discounted price");
        }
Exemplo n.º 6
0
        public void ItemPrice_WhenOnlyMultipleSurvey_ShouldReturnLowestPrice()
        {
            //Arrange
            List <double> surveyList = new List <double>()
            {
                129.0, 120.0, 121.0
            };
            string productName = "ssd";

            double expected = 120.0;

            //Act
            surveyList.ForEach(x =>
            {
                var itemsurvey = new ItemSurvey()
                {
                    ItemName = productName, Price = x, SurveyName = "xxx"
                };
                item.AddSurvey(itemsurvey);
            });

            //Assert
            Assert.AreEqual(expected, item.Price, "Should return lowest price from multiple surveys.");
        }