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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }