public void NextScan_With_System_In_Expedition_But_Everything_Scanned_Communicates_Complete_Phrase() { Celestial celestial = Build.A.Celestial.ThatHasBeenTotallyScanned(); List <StarSystem> systems = Build.A.StarSystem.WithCelestial(celestial).InAList(); _playerStatus.SetLocation(systems.Single().Name); _navigator.PlanExpedition(systems); _sut.Handle(_testEvent); _communicator.MessagesCommunicated.Single().Should().Be(_phrases.ScansComplete.Single()); }
public void ScansRemaining_With_System_In_Expedition_But_No_Scans_Remaining_Communicates_Skip_Phrase() { Celestial celestial = Build.A.Celestial.ThatHasBeenTotallyScanned(); List <StarSystem> systems = Build.A.StarSystem.WithCelestial(celestial).InAList(); _playerStatus.SetLocation(systems.Single().Name); _navigator.PlanExpedition(systems); TestEvent testEvent = Build.An.Event.WithEvent(_sut.SupportedCommand); _sut.Handle(testEvent); _communicator.MessagesCommunicated.Single().Should().Be(_scansRemainingPhrases.SystemComplete.Single()); }
public void RescanSystem_With_System_In_Expedition_Marks_System_As_Unscanned() { TestCommunicator communicator = CreateCommunicator(); Navigator navigator = CreateNavigator(); PlayerStatusRepository playerStatus = CreatePlayerStatusRepository(); var rescanSystemPhrases = TestPhraseBuilder.Build <RescanSystemPhrases>(); var scansRemainingPhrases = TestPhraseBuilder.Build <ScansRemainingPhrases>(); RescanSystemCommand sut = new RescanSystemCommand(communicator, navigator, playerStatus, rescanSystemPhrases, scansRemainingPhrases); Celestial scannedCelestial = Build.A.Celestial.ThatHasBeenScanned(); Celestial unscannedCelestial = Build.A.Celestial.ThatHasNotBeenScanned(); StarSystem firstSystem = Build.A.StarSystem.WithCelestials(scannedCelestial, scannedCelestial, scannedCelestial); StarSystem nextSystem = Build.A.StarSystem.WithCelestials(unscannedCelestial, unscannedCelestial, unscannedCelestial); List <StarSystem> systems = Build.Many.StarSystems(firstSystem); navigator.PlanExpedition(systems); playerStatus.SetLocation(firstSystem.Name); TestEvent testEvent = Build.An.Event.WithEvent(sut.SupportedCommand); sut.Handle(testEvent); List <StarSystem> storedSystems = navigator.GetAllExpeditionSystems(); storedSystems.All(s => s.Scanned == false).Should().BeTrue(); storedSystems.SelectMany(s => s.Celestials).All(s => s.Scanned == false).Should().BeTrue(); navigator.GetNextSystem().Name.ShouldBeEquivalentTo(firstSystem.Name); communicator.MessagesCommunicated.Single().Should().Be(rescanSystemPhrases.SystemUnscanned.Single()); }
public void SkipSystem_With_System_Not_In_Expedition_Does_Nothing() { TestCommunicator communicator = CreateCommunicator(); Navigator navigator = CreateNavigator(); PlayerStatusRepository playerStatus = CreatePlayerStatusRepository(); var skipSystemPhrases = TestPhraseBuilder.Build <SkipSystemPhrases>(); var scansRemainingPhrases = TestPhraseBuilder.Build <ScansRemainingPhrases>(); SkipSystemCommand sut = new SkipSystemCommand(communicator, navigator, playerStatus, skipSystemPhrases, scansRemainingPhrases); Celestial celestial = Build.A.Celestial.ThatHasNotBeenScanned(); StarSystem firstSystem = Build.A.StarSystem.WithCelestials(celestial, celestial, celestial); StarSystem nextSystem = Build.A.StarSystem.WithCelestials(celestial, celestial, celestial); List <StarSystem> systems = Build.Many.StarSystems(firstSystem, nextSystem); navigator.PlanExpedition(systems); playerStatus.SetLocation("Test"); TestEvent testEvent = Build.An.Event.WithEvent(sut.SupportedCommand); sut.Handle(testEvent); List <StarSystem> storedSystems = navigator.GetAllExpeditionSystems(); storedSystems.All(s => s.Scanned == false).Should().BeTrue(); storedSystems.SelectMany(s => s.Celestials).All(s => s.Scanned == false).Should().BeTrue(); navigator.GetNextSystem().ShouldBeEquivalentTo(firstSystem); }
public void SkipSystem_With_System_In_Expedition_Marks_System_As_Scanned() { TestCommunicator communicator = CreateCommunicator(); Navigator navigator = CreateNavigator(); PlayerStatusRepository playerStatus = CreatePlayerStatusRepository(); var skipSystemPhrases = TestPhraseBuilder.Build <SkipSystemPhrases>(); var scansRemainingPhrases = TestPhraseBuilder.Build <ScansRemainingPhrases>(); SkipSystemCommand sut = new SkipSystemCommand(communicator, navigator, playerStatus, skipSystemPhrases, scansRemainingPhrases); Celestial celestial = Build.A.Celestial.ThatHasNotBeenScanned(); StarSystem currentSystem = Build.A.StarSystem.WithCelestials(celestial, celestial, celestial); StarSystem nextSystem = Build.A.StarSystem.WithCelestials(celestial, celestial, celestial); List <StarSystem> systems = Build.Many.StarSystems(currentSystem, nextSystem); navigator.PlanExpedition(systems); playerStatus.SetLocation(currentSystem.Name); TestEvent testEvent = Build.An.Event.WithEvent(sut.SupportedCommand); sut.Handle(testEvent); StarSystem storedSystem = navigator.GetSystem(currentSystem.Name); storedSystem.Scanned.Should().BeTrue(); storedSystem.Celestials.All(c => c.Scanned).Should().BeTrue(); navigator.GetNextSystem().ShouldBeEquivalentTo(nextSystem); }
public void ScanEvent_WithCelestialsRemaining_ShouldUpdateDataStore() { TestPhraseBuilder.Build <CelestialScanPhrases>(); IDataStore <StarSystemDocument> dataStore = CreateDataStore(); Navigator navigator = CreateNavigator(dataStore); PlayerStatusRepository playerStatus = CreatePlayerStatusRepository(); CelestialScanCommand sut = CreateSut(navigator, playerStatus, _phrases); Celestial celestial = Build.A.Celestial; Celestial nextCelestial = Build.A.Celestial; StarSystem currentSystem = Build.A.StarSystem.WithCelestials(celestial, nextCelestial); List <StarSystem> starSystems = Build.Many.StarSystems(currentSystem); navigator.PlanExpedition(starSystems); playerStatus.SetLocation(currentSystem.Name); TestEvent testEvent = Build.An.Event.WithEvent(sut.SupportedCommand) .WithPayload(_payloadKey, celestial.Name); sut.Handle(testEvent); dataStore.FindOne(s => s.Name == currentSystem.Name).Celestials.Single(c => c.Name == celestial.Name).Scanned.Should().BeTrue(); dataStore.FindOne(s => s.Celestials.Any(c => c.Scanned == false)).Name.Should().Be(currentSystem.Name); }
public void ScanEvent_WithSystemNotNextInSequence_ShouldUpdateCorrectSystem() { IDataStore <StarSystemDocument> dataStore = CreateDataStore(); Navigator navigator = CreateNavigator(dataStore); PlayerStatusRepository playerStatus = CreatePlayerStatusRepository(); CelestialScanCommand sut = CreateSut(navigator, playerStatus, _phrases); Celestial celestial = Build.A.Celestial; StarSystem firstSystem = Build.A.StarSystem.WithCelestial(Build.A.Celestial); StarSystem secondSystem = Build.A.StarSystem.WithCelestial(celestial); StarSystem thirdSystem = Build.A.StarSystem.WithCelestial(celestial); List <StarSystem> starSystems = Build.Many.StarSystems(firstSystem, secondSystem, thirdSystem); navigator.PlanExpedition(starSystems); playerStatus.SetLocation(secondSystem.Name); TestEvent testEvent = Build.An.Event.WithEvent(sut.SupportedCommand) .WithPayload(_payloadKey, celestial.Name); sut.Handle(testEvent); StarSystemDocument firstSystemStored = dataStore.FindOne(s => s.Name == firstSystem.Name); StarSystemDocument secondSystemStored = dataStore.FindOne(s => s.Name == secondSystem.Name); StarSystemDocument thirdSystemStored = dataStore.FindOne(s => s.Name == thirdSystem.Name); firstSystemStored.Scanned.Should().BeFalse(); firstSystemStored.Celestials.All(c => c.Scanned == false).Should().BeTrue(); secondSystemStored.Scanned.Should().BeTrue(); secondSystemStored.Celestials.All(c => c.Scanned).Should().BeTrue(); thirdSystemStored.Scanned.Should().BeFalse(); thirdSystemStored.Celestials.All(c => c.Scanned == false).Should().BeTrue(); }
public void LocationCommand_Should_UpdateLocation() { PlayerStatusRepository repository = CreatePlayerStatusRepository(); LocationCommand sut = CreateSut(repository); repository.SetLocation(Build.A.StarSystem.Name); string expectedSystem = Build.A.StarSystem.Name; TestEvent loadEvent = Build.An.Event.WithEvent("LoadGame").WithPayload("StarSystem", expectedSystem); sut.Handle(loadEvent); repository.Location.Should().Be(expectedSystem); }
public void ScannedEvent_WithProbesGreaterThanTarget_ShouldUpdateEfficient_False() { IDataStore <StarSystemDocument> dataStore = CreateDataStore(); Navigator navigator = CreateNavigator(dataStore); PlayerStatusRepository playerStatus = CreatePlayerStatusRepository(); CelestialSurfaceScanCommand sut = CreateSut(navigator, playerStatus, _phrases); Celestial celestial = Build.A.Celestial; StarSystem currentSystem = Build.A.StarSystem.WithCelestial(celestial); List <StarSystem> starSystems = Build.Many.StarSystems(currentSystem); navigator.PlanExpedition(starSystems); playerStatus.SetLocation(currentSystem.Name); TestEvent testEvent = Build.An.Event.WithEvent(sut.SupportedCommand) .WithPayload(_payloadKey, celestial.Name) .WithPayload(_payloadProbe, 8) .WithPayload(_payloadTarget, 4); sut.Handle(testEvent); dataStore.FindOne(s => s.Name == currentSystem.Name).Celestials.Single().Efficient.Should().BeFalse(); }
public void RescanSystem_With_System_Not_In_Expedition_Does_Nothing() { TestCommunicator communicator = CreateCommunicator(); Navigator navigator = CreateNavigator(); PlayerStatusRepository playerStatus = CreatePlayerStatusRepository(); var rescanSystemPhrases = TestPhraseBuilder.Build <RescanSystemPhrases>(); var scansRemainingPhrases = TestPhraseBuilder.Build <ScansRemainingPhrases>(); RescanSystemCommand sut = new RescanSystemCommand(communicator, navigator, playerStatus, rescanSystemPhrases, scansRemainingPhrases); Celestial celestial = Build.A.Celestial.ThatHasBeenScanned(); List <StarSystem> systems = Build.A.StarSystem.WithCelestial(celestial).InAList(); navigator.PlanExpedition(systems); playerStatus.SetLocation("Test"); TestEvent testEvent = Build.An.Event.WithEvent(sut.SupportedCommand); sut.Handle(testEvent); navigator.GetAllExpeditionSystems().ShouldAllBeEquivalentTo(systems); communicator.MessagesCommunicated.Single().Should().Be(scansRemainingPhrases.SkipSystem.Single()); }
public void ScanEvent_WithSameCelestialScanned_ShouldDoNothing() { IDataStore <StarSystemDocument> dataStore = CreateDataStore(); Navigator navigator = CreateNavigator(dataStore); PlayerStatusRepository playerStatus = CreatePlayerStatusRepository(); CelestialScanCommand sut = CreateSut(navigator, playerStatus, _phrases); Celestial celestial = Build.A.Celestial; StarSystem currentSystem = Build.A.StarSystem.WithCelestial(celestial); List <StarSystem> starSystems = Build.Many.StarSystems(currentSystem); navigator.PlanExpedition(starSystems); playerStatus.SetLocation(currentSystem.Name); TestEvent testEvent = Build.An.Event.WithEvent(sut.SupportedCommand) .WithPayload(_payloadKey, celestial.Name); sut.Handle(testEvent); var storedSystem = dataStore.FindOne(s => s.Name == currentSystem.Name); storedSystem.Scanned.Should().BeTrue(); storedSystem.Celestials.Single().Scanned.Should().BeTrue(); }