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);
        }
Esempio n. 2
0
        public CancelExpeditionCommandTests()
        {
            TestCommunicator communicator = CreateCommunicator();

            _navigator = CreateNavigator(new MemoryDataStore <StarSystemDocument>());
            _sut       = new CancelExpeditionCommand(communicator, _navigator, CreatePhrases <CancelExpeditionPhrases>());
        }
        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 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 ScansRemainingCommandTests()
 {
     _communicator          = CreateCommunicator();
     _navigator             = CreateNavigator();
     _playerStatus          = CreatePlayerStatusRepository();
     _scansRemainingPhrases = TestPhraseBuilder.Build <ScansRemainingPhrases>();
     _sut = new ScansRemainingCommand(_communicator, _navigator, _playerStatus, _scansRemainingPhrases);
 }
Esempio n. 6
0
        public NextScanCommandTests()
        {
            _phrases      = TestPhraseBuilder.Build <NextScanPhrases>();
            _communicator = CreateCommunicator();
            _playerStatus = CreatePlayerStatusRepository();
            _navigator    = CreateNavigator();

            _sut       = new NextScanCommand(_communicator, _navigator, _playerStatus, _phrases);
            _testEvent = Build.An.Event.WithEvent(_sut.SupportedCommand);
        }
        public ExtendExpeditionCommandTests()
        {
            Celestial celestial = Build.A.Celestial.ThatHasNotBeenScanned();

            _starSystems     = Build.A.StarSystem.WithCelestial(celestial).InAList();
            _userDataService = new TestUserDataService(_starSystems);
            _navigator       = CreateNavigator(new MemoryDataStore <StarSystemDocument>());
            _communicator    = CreateCommunicator();
            _sut             = new ExtendExpeditionCommand(_communicator, _navigator, _userDataService, BuildPhrases());
        }
Esempio n. 8
0
        public JumpCommandTests()
        {
            Celestial celestial  = Build.A.Celestial.ThatHasNotBeenScanned();
            Celestial celestial2 = Build.A.Celestial.ThatHasNotBeenScanned();

            _starSystems     = Build.A.StarSystem.WithCelestials(celestial, celestial, celestial2).InAList();
            _userDataService = new TestUserDataService(_starSystems);
            _navigator       = CreateNavigator(new MemoryDataStore <StarSystemDocument>());
            _communicator    = CreateCommunicator();
        }
        public void GameLoad_Should_StoreFuelCapacity()
        {
            TestCommunicator communicator = CreateCommunicator();
            DockSRVPhrases   phrases      = TestPhraseBuilder.Build <DockSRVPhrases>();
            DockSRVCommand   sut          = new DockSRVCommand(communicator, phrases);

            TestEvent loadEvent = Build.An.Event.WithEvent("DockSRV");

            sut.Handle(loadEvent);

            communicator.MessagesCommunicated.Single().Should().Be(phrases.Phrases.Single());
        }
        public PlanExpeditionCommandTests()
        {
            PlayerStatusRepository playerStatus = CreatePlayerStatusRepository();
            Celestial celestial = Build.A.Celestial.ThatHasNotBeenScanned();

            _starSystems = Build.A.StarSystem.WithCelestial(celestial).InAList();

            _userDataService = new TestUserDataService(_starSystems);
            _navigator       = CreateNavigator(new MemoryDataStore <StarSystemDocument>());
            _communicator    = CreateCommunicator();
            _sut             = new PlanExpeditionCommand(_communicator, _navigator, _userDataService, playerStatus, BuildPhrases(), new CelestialValues(), new DetourPlanner(_navigator, null, playerStatus, null));;
        }
Esempio n. 11
0
        public void DockSRV_Command_Should_Not_Communicate_Phrase_When_Disabled()
        {
            var preferences = new Preferences()
            {
                EnableSRVCommands = false
            };
            TestCommunicator communicator = CreateCommunicator();
            DockSRVPhrases   phrases      = TestPhraseBuilder.Build <DockSRVPhrases>();
            DockSRVCommand   sut          = new DockSRVCommand(communicator, phrases, preferences);

            TestEvent loadEvent = Build.An.Event.WithEvent("DockSRV");

            sut.Handle(loadEvent);

            communicator.MessagesCommunicated.Single().Should().BeEmpty();
        }
        public void GameLoad_Should_StoreFuelCapacity()
        {
            TestCommunicator       communicator = CreateCommunicator();
            PlayerStatusRepository repository   = CreatePlayerStatusRepository();
            GameLoadPhrases        phrases      = TestPhraseBuilder.Build <GameLoadPhrases>();
            GameLoadCommand        sut          = new GameLoadCommand(communicator, repository, phrases);

            double fuelCapacity = 100;

            TestEvent loadEvent = Build.An.Event.WithEvent("LoadGame").WithPayload("FuelCapacity", fuelCapacity);

            sut.Handle(loadEvent);

            repository.FuelCapacity.Should().Be(fuelCapacity);
            communicator.MessagesCommunicated.Single().Should().Be(phrases.Generic.Single());
        }
        public void GetNextSystem_Communicates_NextSystem()
        {
            TestCommunicator      communicator = CreateCommunicator();
            Navigator             navigator    = CreateNavigator();
            TestGalaxyMap         galaxyMap    = new TestGalaxyMap();
            FindNextSystemCommand sut          = new FindNextSystemCommand(communicator, navigator, galaxyMap, TestPhraseBuilder.Build <FindNextSystemPhrases>(), CreatePlayerStatusRepository());

            TestEvent testEvent = Build.An.Event.WithEvent(sut.SupportedCommand);

            Celestial  celestial = Build.A.Celestial.ThatHasNotBeenScanned();
            StarSystem system    = Build.A.StarSystem.WithCelestial(celestial);

            navigator.PlanExpedition(new[] { system });

            sut.Handle(testEvent);

            galaxyMap.Systems.Single().Should().Be(system.Name);
        }
        public void GetNextSystem_Communicates_NextSystem()
        {
            TestCommunicator     communicator = CreateCommunicator();
            Navigator            navigator    = CreateNavigator();
            GetNextSystemPhrases phrases      = new GetNextSystemPhrases {
                Phrases = new[] { "{0}" }
            };
            GetNextSystemCommand sut = new GetNextSystemCommand(communicator, navigator, phrases);

            TestEvent testEvent = Build.An.Event.WithEvent(sut.SupportedCommand);

            Celestial  celestial = Build.A.Celestial.ThatHasNotBeenScanned();
            StarSystem system    = Build.A.StarSystem.WithCelestial(celestial);

            navigator.PlanExpedition(new[] { system });

            sut.Handle(testEvent);

            communicator.MessagesCommunicated.Single().Should().Be(system.Name);
        }
        public void GetNextSystem_Gets_Original_Destination_After_Expedition_Is_Done()
        {
            TestCommunicator       communicator = CreateCommunicator();
            Navigator              navigator    = CreateNavigator();
            TestGalaxyMap          galaxyMap    = new TestGalaxyMap();
            PlayerStatusRepository repo         = CreatePlayerStatusRepository();
            FindNextSystemCommand  sut          = new FindNextSystemCommand(communicator, navigator, galaxyMap, TestPhraseBuilder.Build <FindNextSystemPhrases>(), repo);
            string originalDestination          = "OriginalDestination";

            repo.SetDestination(originalDestination);
            TestEvent testEvent = Build.An.Event.WithEvent(sut.SupportedCommand);

            Celestial  celestial = Build.A.Celestial.ThatHasBeenTotallyScanned();
            StarSystem system    = Build.A.StarSystem.WithCelestial(celestial);

            navigator.PlanExpedition(new[] { system });

            sut.Handle(testEvent);

            galaxyMap.Systems.Single().Should().Be(originalDestination);
        }
Esempio n. 16
0
        public void ProgressCommand_Communicates_Progress()
        {
            TestCommunicator       communicator = CreateCommunicator();
            Navigator              navigator    = CreateNavigator();
            PlayerStatusRepository playerStatus = CreatePlayerStatusRepository();
            ProgressPhrases        phrases      = TestPhraseBuilder.Build <ProgressPhrases>();

            ProgressCommand sut = new ProgressCommand(communicator, navigator, playerStatus, phrases);

            Celestial         celestial = Build.A.Celestial;
            List <StarSystem> systems   = Build.A.StarSystem.WithCelestials(celestial).InAList();

            navigator.PlanExpedition(systems);

            TestEvent testEvent = Build.An.Event.WithEvent(sut.SupportedCommand);

            sut.Handle(testEvent);

            communicator.MessagesCommunicated[0].Should().Be(phrases.Progress.Single());
            communicator.MessagesCommunicated[1].Should().Be(phrases.SystemsScanned.Single());
            communicator.MessagesCommunicated[2].Should().Be(phrases.CreditsEarned.Single());
        }
Esempio n. 17
0
        public void Test_GetDataFromFileName()
        {
            var communicator = new TestCommunicator(userInput: new[] {
                "1",
                "1",
            });

            var item = new TestMp3File("2. name2 - title2.mp3")
            {
                TrackId = "1", Title = "title2", Artist = "name1"
            };

            var files = new[] { item };

            var syncer = new Mp3Syncing(files, "{id}. {artist} - {title}", communicator, new TestRollbackSaver(new[] { "" }));

            syncer.SyncFiles();

            Assert.AreEqual(item.TrackId, "2");
            Assert.AreEqual(item.Artist, "name2");
            Assert.AreEqual(item.Title, "title2");
        }
Esempio n. 18
0
        public void Test_GetDataFromUser()
        {
            var communicator = new TestCommunicator(userInput: new[] {
                "3",
                "3",                 //it's entering a value
            });

            var item = new TestMp3File("1. name3 - title3.mp3")
            {
                TrackId = "3", Title = "title3", Artist = "name3"
            };

            var files = new[] { item };

            var syncer = new Mp3Syncing(files, "{id}. {artist} - {title}", communicator, new TestRollbackSaver(new[] { "" }));

            syncer.SyncFiles();

            Assert.AreEqual(item.TrackId, "3");
            Assert.AreEqual(item.Artist, "name3");
            Assert.AreEqual(item.Title, "title3");
        }
        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());
        }