Beispiel #1
0
        public void Can_Get_Stations_By_Route()
        {
            //Setup
            Mock <IStationRepository> mock = new Mock <IStationRepository>();

            mock.Setup(m => m.Stations).Returns(new Station[] {
                new Station {
                    Id = "1", Name = "S1", Route = "Troncal"
                },
                new Station {
                    Id = "2", Name = "S2", Route = "Troncal"
                },
                new Station {
                    Id = "3", Name = "S3", Route = "Troncal"
                },
                new Station {
                    Id = "4", Name = "S4", Route = "Different"
                },
                new Station {
                    Id = "5", Name = "S5", Route = "Different"
                }
            }.AsQueryable());
            StationsController stationController = new StationsController(mock.Object);

            stationController.PageSize = 5;

            //Act
            StationListViewModel result = (StationListViewModel)stationController.ByRoute("Troncal").Model;

            //Assert
            Station[] stationArray = result.Stations.ToArray();
            Assert.IsTrue(stationArray.Length == 3);
            Assert.AreEqual(stationArray[0].Name, "S1");
            Assert.AreEqual(stationArray[1].Name, "S2");
        }