public void PotterTotalNoDiscounts()
        {
            //Arrange
            int[]      bookArray     = { 0 };
            KataPotter potter        = new KataPotter();
            decimal    expectedTotal = (8M * 1);

            //Act
            decimal actualCost = potter.GetCost(bookArray);

            //Assert
            Assert.AreEqual(expectedTotal, actualCost);

            //Arrange
            bookArray     = new int[] { 0, 0 };
            expectedTotal = (8M * 2);

            //Act
            actualCost = potter.GetCost(bookArray);

            //Assert
            Assert.AreEqual(expectedTotal, actualCost);

            //Arrange
            bookArray     = new int[] { 4, 4, 4, 4, 4 };
            expectedTotal = (8M * 5);

            //Act
            actualCost = potter.GetCost(bookArray);

            //Assert
            Assert.AreEqual(expectedTotal, actualCost);
        }
Beispiel #2
0
        public void TestPotter(double expectedResult, int[] books)
        {
            // Arrange
            // Create a new Potter object
            KataPotter subject = new KataPotter();

            // Act
            double actualResult = subject.GetCost(books);

            // Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
        public void PotterNoPurchase()
        {
            //Arrange
            int[]      emptyArray    = { };
            KataPotter potter        = new KataPotter();
            decimal    expectedTotal = (8M * 0);

            //Act
            decimal actualCost = potter.GetCost(emptyArray);

            //Assert
            Assert.AreEqual(expectedTotal, actualCost);
        }
Beispiel #4
0
        public void PotterTest()
        {
            KataPotter thisKata = new KataPotter();

            int[] books1 = { 3, 2, 1, 5, 1, 3 };
            Assert.AreEqual(40.8M, thisKata.GetCost(books1));
            //int[] books2 = { 1, 2, 4, 3, 5, 3, 2 };
            //Assert.AreEqual(42, thisKata.GetCost(books2));
            int[] books3 = { 2 };
            Assert.AreEqual(8, thisKata.GetCost(books3));
            int[] books4 = { 1, 2, 4, 5 };
            Assert.AreEqual(25.6M, thisKata.GetCost(books4));
            int[] books5 = { 2, 4 };
            Assert.AreEqual(15.2M, thisKata.GetCost(books5));
        }
        public void PotterSameBookDiscounts()
        {
            //Arrange
            KataPotter potterArrays = new KataPotter();

            int[] oneBookArray = { 0, 0, 1, 1 };


            decimal expectedTotal = (2 * (8M * 2 * 0.95M));

            //Act
            decimal actualCost = potterArrays.GetCost(oneBookArray);

            //Assert
            Assert.AreEqual(expectedTotal, actualCost);
        }
        public void PotterDiscountsForOneGroup()
        {
            //Arrange
            int[]      bookArray     = { 0, 1 };
            KataPotter potter        = new KataPotter();
            decimal    expectedTotal = (8M * 2 * 0.95M);

            //Act
            decimal actualCost = potter.GetCost(bookArray);

            //Assert
            Assert.AreEqual(expectedTotal, actualCost);

            //Arrange
            bookArray = new int[] { 0, 1, 2 };

            expectedTotal = (8M * 3 * 0.90M);

            //Act
            actualCost = potter.GetCost(bookArray);

            //Assert
            Assert.AreEqual(expectedTotal, actualCost);

            //Arrange
            bookArray = new int[] { 0, 1, 2, 3 };

            expectedTotal = (8M * 4 * 0.80M);

            //Act
            actualCost = potter.GetCost(bookArray);

            //Assert
            Assert.AreEqual(expectedTotal, actualCost);

            //Arrange
            bookArray = new int[] { 0, 1, 2, 3, 4 };

            expectedTotal = (8M * 5 * 0.75M);

            //Act
            actualCost = potter.GetCost(bookArray);

            //Assert
            Assert.AreEqual(expectedTotal, actualCost);
        }
        public void Potter_TestPrice()
        {
            testPotter = new KataPotter(new int[] { 2, 2, 2, 1, 1 });
            Assert.AreEqual(51.20M, testPotter.GetCost(), "Price should be $51.20");

            testPotter = new KataPotter(new int[] { 4, 4, 1, 5, 2 });
            Assert.AreEqual(101.6M, testPotter.GetCost(), "Price should be $101.6");

            testPotter = new KataPotter(new int[] { 4, 2, 0, 6, 1 });
            Assert.AreEqual(75.2M, testPotter.GetCost(), "Price should be $75.2");

            testPotter = new KataPotter(new int[] { 5, 5, 5, 0, 0 });
            Assert.AreEqual(84M, testPotter.GetCost(), "Price should be $84.00");

            testPotter = new KataPotter(new int[] { 3, 3, 7, 7, 7 });
            Assert.AreEqual(170.4M, testPotter.GetCost(), "Price should be $170.4");

            testPotter = new KataPotter(new int[] { 4, 4, 4, 3, 3 });
            Assert.AreEqual(119.2M, testPotter.GetCost(), "Price should be $119.20");
        }
        public void Potter_TestSort()
        {
            testPotter = new KataPotter(new int[] { 2, 2, 2, 1, 1 });
            CollectionAssert.AreEqual(new int[] { 0, 0, 0, 2, 0 }, testPotter.Collection);

            testPotter = new KataPotter(new int[] { 4, 4, 1, 5, 2 });
            CollectionAssert.AreEqual(new int[] { 1, 0, 1, 3, 0 }, testPotter.Collection);


            testPotter = new KataPotter(new int[] { 4, 2, 0, 6, 1 });
            CollectionAssert.AreEqual(new int[] { 2, 2, 1, 1, 0 }, testPotter.Collection);

            testPotter = new KataPotter(new int[] { 5, 5, 5, 0, 0 });
            CollectionAssert.AreEqual(new int[] { 0, 0, 5, 0, 0 }, testPotter.Collection);


            testPotter = new KataPotter(new int[] { 3, 3, 7, 7, 7 });
            CollectionAssert.AreEqual(new int[] { 0, 0, 1, 6, 0 }, testPotter.Collection);

            testPotter = new KataPotter(new int[] { 4, 4, 4, 3, 3 });
            CollectionAssert.AreEqual(new int[] { 0, 0, 0, 2, 2 }, testPotter.Collection);
        }
 public void Setup()
 {
     KataPotter PotterBooks = new KataPotter();
 }
Beispiel #10
0
 public void Initialize()
 {
     kataPotter = new KataPotter();
     inputArray = new int[] { 0, 0, 0, 0, 0 };
 }