コード例 #1
0
        public void Index_Get_IndexView_UserWithPreferenceUpvote_1Event_Validate_1Pin()
        {
            // Arrange
            List<Models.TruckEvent> testEvents = new List<TruckEvent>()
            {
                new TruckEvent() {
                    Name = "TestTruck1",
                    Url = "www.testtruck1.com",
                    Day = "Friday",
                    Time = "Lunch",
                    Neighborhood = "NEU, on Opera Place at Huntington Ave",
                    Coordinates = new Location("42.3398106,-71.0913604")
                },
            };
            List<Models.Preference.PreferenceData> testPreferences = new List<Preference.PreferenceData>()
            {
                new Preference.PreferenceData() {
                    userid = "TestUser1",
                    truckname = "TestTruck1",
                    preference = 1  // Upvote
                },
            };
            var user = new MockCurrentUser();
            user.setUserId("TestUser1");
            var controller = new HomeController(
                new MockPreferenceRepository(testPreferences),
                new MockTruckDataRepository(testEvents),
                user);

            // Act
            ViewResult result = controller.Index(setDay: "Friday", setMeal: "Lunch");

            // Assert
            var pinsString = result.ViewData["CurrentTruckPins"] as string;
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            List<Models.TruckPushpinInfo> pins = serializer.Deserialize<List<Models.TruckPushpinInfo>>(pinsString);
            Assert.IsNotNull(pins);
            Assert.AreEqual(pins.Count, 1);
            Assert.AreEqual(pins[0].truckName, "TestTruck1");
            Assert.AreEqual(pins[0].location, "NEU, on Opera Place at Huntington Ave");
            Assert.AreEqual(pins[0].longitude, (Double)(-71.0913604));
            Assert.AreEqual(pins[0].preference, 1);
        }
コード例 #2
0
        public void Index_Get_IndexView_Empty_ViewNameIndex()
        {
            // Arrange
            var controller = new HomeController(
                new MockPreferenceRepository(),
                new MockTruckDataRepository(),
                new MockCurrentUser());

            // Act
            ViewResult result = controller.Index();

            // Assert
            Assert.AreEqual("Index", result.ViewName);
        }
コード例 #3
0
        public void Index_Get_IndexView_Empty_Neighborhoods_Contains_ShowAll()
        {
            // Arrange
            var controller = new HomeController(
                new MockPreferenceRepository(),
                new MockTruckDataRepository(),
                new MockCurrentUser());

            // Act
            ViewResult result = controller.Index();

            // Assert
            var neighborhoods = result.ViewData["CurrentNeighborhoods"] as SelectList;
            Assert.AreEqual(neighborhoods.SelectedValue, Constants.AllNeighborhoodsString);
            var trucknames = result.ViewData["CurrentTrucks"] as SelectList;
            Assert.AreEqual(trucknames.SelectedValue, Constants.AllTrucksString);
        }
コード例 #4
0
        public void Index_Get_IndexView_Empty_NotNull()
        {
            // Arrange
            var controller = new HomeController(
                new MockPreferenceRepository(),
                new MockTruckDataRepository(),
                new MockCurrentUser());

            // Act
            ViewResult result = controller.Index();

            // Assert
            Assert.IsNotNull(result);
        }
コード例 #5
0
        public void Index_Get_IndexView_Empty_Contains_NoPins()
        {
            // Arrange
            var controller = new HomeController(
                new MockPreferenceRepository(),
                new MockTruckDataRepository(),
                new MockCurrentUser());

            // Act
            ViewResult result = controller.Index();

            // Assert
            var pins = result.ViewData["CurrentTruckPins"] as List<Models.TruckPushpinInfo>;
            Assert.IsNull(pins);
        }