public void LaunchListSortsTwoLaunches() { // 1. Create LaunchInfoProviderStub (that implements ISpacelineLaunchInfoProvider) // 2/3. Create SUT - SpaceportDepartureBoard, using Constructor Injection // 4. Exercise the SUT // 5. Verify the results are sorted correctly LaunchInfoProviderStub fakeProvider = new LaunchInfoProviderStub(); LaunchInfo newInfo = new LaunchInfo(); newInfo.Destination = "Saturn"; fakeProvider.launchInfoList.Add(newInfo); newInfo = new LaunchInfo(); newInfo.Destination = "Neptune"; fakeProvider.launchInfoList.Add(newInfo); SpaceportDepartureBoard board = new SpaceportDepartureBoard(fakeProvider); Assert.IsNotEmpty(board.LaunchList); Assert.AreEqual(2, board.LaunchList.Count); Assert.AreEqual("Neptune", board.LaunchList[0].Destination); Assert.AreEqual("Saturn", board.LaunchList[1].Destination); }
public void SpaceportDepartureBoard_LaunchInfoSortedByDestination() { // Arrange var mock = new MockProvider(); var launch1 = new LaunchInfo(); launch1.Destination = "Jupiter"; var launch2 = new LaunchInfo(); launch2.Destination = "Oort Cloud"; var launch3 = new LaunchInfo(); launch3.Destination = "Hoth"; var myList = new List <LaunchInfo>(); myList.Add(launch1); myList.Add(launch2); myList.Add(launch3); mock.listOfLaunches = myList; // Act var board = new SpaceportDepartureBoard(mock); // Assert var expected = new List <LaunchInfo>(); expected.Add(launch3); expected.Add(launch1); expected.Add(launch2); Assert.AreEqual(expected, board.LaunchList); Assert.AreEqual("Hoth", board.LaunchList[0].Destination, "Hoth is first alphabetically"); Assert.AreEqual("Jupiter", board.LaunchList[1].Destination, "Jupiter is second alphabetically"); Assert.AreEqual("Oort Cloud", board.LaunchList[2].Destination, "Oort Cloud is third alphabetically"); }
public void LaunchListCreatesWithSingleLaunch() { // 1. Create LaunchInfoProviderStub (that implements ISpacelineLaunchInfoProvider) // 2/3. Create SUT - SpaceportDepartureBoard, using Constructor Injection // 4. Exercise the SUT // 5. Verify the results are sorted correctly ISpacelineLaunchInfoProvider fakeProvider = new LaunchInfoProviderStub(); SpaceportDepartureBoard board = new SpaceportDepartureBoard(fakeProvider); LaunchInfo newInfo = new LaunchInfo(); newInfo.Destination = "Mars"; board.OnNext(newInfo); Assert.IsNotEmpty(board.LaunchList); Assert.AreEqual(1, board.LaunchList.Count); Assert.AreEqual("Mars", board.LaunchList[0].Destination); }