コード例 #1
0
        public void GetItemInSectionTestSectionNameIsNullReturnsJSONErrorMessage()
        {
            var result = (JsonResult)itemcontroller.GetItemsInSection(null);
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            ForJsonResults       values     = serializer.Deserialize <ForJsonResults>(serializer.Serialize(result.Data));

            Assert.AreEqual("Section name was null or empty", values.error);
        }
コード例 #2
0
        public void GetAllStoreNamesReturnsOneStore()
        {
            var result = (JsonResult)storeController.GetAllStoreNames();
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            ForJsonResults       values     = serializer.Deserialize <ForJsonResults>(serializer.Serialize(result.Data));

            Assert.AreEqual(1, values.storenames.Count);
        }
コード例 #3
0
        public void GetItemInSectionTestBadSectionNameReturnsJSONErrorMessage()
        {
            var result = (JsonResult)itemcontroller.GetItemsInSection("asfdsafd");
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            ForJsonResults       values     = serializer.Deserialize <ForJsonResults>(serializer.Serialize(result.Data));

            Assert.AreEqual("Did not find any items for that given section", values.error);
        }
コード例 #4
0
        public void GetItemInSectionTest()
        {
            var result = (JsonResult)itemcontroller.GetItemsInSection("cakemix");
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            ForJsonResults       values     = serializer.Deserialize <ForJsonResults>(serializer.Serialize(result.Data));

            Assert.AreEqual(2, values.itemsfound.Count);
        }
コード例 #5
0
        public void CreateStoreMapTestStoreIdIsNotInDatabase()
        {
            var result = (JsonResult)storeController.CreateStoreMap(4, 4, 5, false, false, false, 4);

            JavaScriptSerializer serializer = new JavaScriptSerializer();
            ForJsonResults       values     = serializer.Deserialize <ForJsonResults>(serializer.Serialize(result.Data));

            Assert.AreEqual("The store was not found", values.error);
        }
コード例 #6
0
        public void CreateStoreMapTestShelvesEqualsZero()
        {
            var result = (JsonResult)storeController.CreateStoreMap(4, 0, 5, false, false, false, 1);

            JavaScriptSerializer serializer = new JavaScriptSerializer();
            ForJsonResults       values     = serializer.Deserialize <ForJsonResults>(serializer.Serialize(result.Data));

            Assert.AreEqual("Aisles, Sections and/or Shelves equals zero. They all must be greater than zero.", values.error);
        }
コード例 #7
0
        public void AddSectionToStoreMapTestEmptyStringsReturnSuccessFalse()
        {
            var result = (JsonResult)storeController.AddSectionToStoreMap("", "", 1);

            JavaScriptSerializer serializer = new JavaScriptSerializer();
            ForJsonResults       values     = serializer.Deserialize <ForJsonResults>(serializer.Serialize(result.Data));


            Assert.IsFalse(values.success);
        }
コード例 #8
0
        public void CreateStoreMapTestStoreSuccessIsTrueAndStoreMapCountIsTwoAndShelvesCountIsSeven()
        {
            var result = (JsonResult)storeController.CreateStoreMap(4, 4, 5, false, false, false, 1);

            JavaScriptSerializer serializer = new JavaScriptSerializer();
            ForJsonResults       values     = serializer.Deserialize <ForJsonResults>(serializer.Serialize(result.Data));

            Assert.AreEqual(2, _dataRepository.GetAllStoreMaps().Count);
            Assert.AreEqual(7, _dataRepository.GetAllShelves().Count);
            Assert.IsTrue(values.success);
        }
コード例 #9
0
        public void CreateStoreMapTestStoreSuccessIsTrueAndCheckAllDataOfCreatedStoreMap()
        {
            var result = (JsonResult)storeController.CreateStoreMap(4, 4, 5, false, false, true, 1);

            JavaScriptSerializer serializer = new JavaScriptSerializer();
            ForJsonResults       values     = serializer.Deserialize <ForJsonResults>(serializer.Serialize(result.Data));

            Assert.AreEqual(4, _dataRepository.GetStoreMapById(2).Aisles);
            Assert.AreEqual(4, _dataRepository.GetStoreMapById(2).ShelvesCount);
            Assert.IsFalse(_dataRepository.GetStoreMapById(2).BackWall);
            Assert.IsFalse(_dataRepository.GetStoreMapById(2).RightSection);
            Assert.IsTrue(_dataRepository.GetStoreMapById(2).LeftSection);

            Assert.IsTrue(values.success);
        }
コード例 #10
0
        public void AddSectionToStoreMapTestSuccessIsTrue()
        {
            var result = (JsonResult)storeController.AddSectionToStoreMap("2", "2_2_10_10", 1);

            JavaScriptSerializer serializer = new JavaScriptSerializer();
            ForJsonResults       values     = serializer.Deserialize <ForJsonResults>(serializer.Serialize(result.Data));

            Assert.AreEqual(2, values.data.Id);
            Assert.AreEqual("2", values.data.Name);
            Assert.AreEqual(2, values.data.Number);
            Assert.AreEqual(2, values.data.ShelfName);
            Assert.AreEqual(10, values.data.Xcoord);
            Assert.AreEqual(10, values.data.Ycoord);
            Assert.IsTrue(values.success);
        }