Пример #1
0
        public void TestEddbGetSystem()
        {
            // Setup
            string      resource = "v4/populatedsystems?";
            string      json     = Encoding.UTF8.GetString(Resources.bgsEddbSystemResponse);
            RestRequest data     = new RestRequest();

            StarSystem expectedSol = new StarSystem()
            {
                systemAddress = 10477373803,
                systemname    = "Sol",
                EDSMID        = 27,
                Power         = Power.FromEDName("ZacharyHudson"),
                powerState    = PowerplayState.FromEDName("Controlled"),
                updatedat     = 1599446773
            };

            // Act
            fakeEddbRestClient.Expect(resource, json, data);
            StarSystem solByName    = fakeBgsService.GetSystemByName("Sol");
            StarSystem solByAddress = fakeBgsService.GetSystemBySystemAddress(10477373803);

            fakeEddbRestClient.Expect(resource, "", data);
            StarSystem nonExistentSystem = fakeBgsService.GetSystemByName("No such system");

            // Assert
            Assert.IsTrue(solByName.DeepEquals(expectedSol));
            Assert.IsTrue(solByAddress.DeepEquals(expectedSol));
            Assert.IsNull(nonExistentSystem);
        }
Пример #2
0
        public void TestBgsFactionFromName()
        {
            // Setup
            string      resource = "v4/factions?";
            string      json     = Encoding.UTF8.GetString(Resources.bgsFactionResponse);
            RestRequest data     = new RestRequest();

            fakeBgsRestClient.Expect(resource, json, data);

            // Act
            Faction faction1 = fakeBgsService.GetFactionByName("The Dark Wheel");

            // Assert
            Assert.IsNotNull(faction1);
            Assert.AreEqual("The Dark Wheel", faction1.name);
            Assert.AreEqual("Democracy", faction1.Government.invariantName);
            Assert.AreEqual("Independent", faction1.Allegiance.invariantName);
            Assert.AreEqual(41917, faction1.EDDBID);
            Assert.AreNotEqual(DateTime.MinValue, faction1.updatedAt);

            // Even if the faction does not exist, we should return a basic object
            Faction faction2 = fakeBgsService.GetFactionByName("No such faction");

            Assert.IsNotNull(faction2);
            Assert.AreEqual("No such faction", faction2.name);
            Assert.AreEqual(Government.None, faction2.Government);
            Assert.AreEqual(Superpower.None, faction2.Allegiance);
            Assert.AreEqual(DateTime.MinValue, faction2.updatedAt);
        }
Пример #3
0
        public void TestBgsFactionFromName()
        {
            // Setup
            string      resource = "v5/factions?";
            string      json     = Encoding.UTF8.GetString(Resources.bgsFactionResponse);
            RestRequest data     = new RestRequest();

            fakeBgsRestClient.Expect(resource, json, data);

            // Act
            Faction faction1 = fakeBgsService.GetFactionByName("The Dark Wheel");

            // Assert
            Assert.IsNotNull(faction1);
            Assert.AreEqual("The Dark Wheel", faction1.name);
            Assert.AreEqual("Democracy", faction1.Government.invariantName);
            Assert.AreEqual("Independent", faction1.Allegiance.invariantName);
            Assert.AreEqual(41917, faction1.EDDBID);
            Assert.AreNotEqual(DateTime.MinValue, faction1.updatedAt);
            Assert.AreEqual(14, faction1.presences.Count);
            var presence = faction1.presences.FirstOrDefault(p => p.systemName == "Shinrarta Dezhra");

            Assert.IsNotNull(presence);
            Assert.AreEqual(FactionState.FromEDName("civilunrest"), presence.FactionState);
            Assert.AreEqual(28.0719M, presence.influence);
            Assert.AreEqual(Happiness.FromEDName("$Faction_HappinessBand1"), presence.Happiness);
            Assert.AreEqual(1, presence.ActiveStates.Count);
            Assert.AreEqual(FactionState.FromEDName("civilunrest"), presence.ActiveStates[0]);
            Assert.AreEqual(0, presence.PendingStates.Count);
            Assert.AreEqual(0, presence.RecoveringStates.Count);

            // Even if the faction does not exist, we should return a basic object
            Faction faction2 = fakeBgsService.GetFactionByName("No such faction");

            Assert.IsNotNull(faction2);
            Assert.AreEqual("No such faction", faction2.name);
            Assert.AreEqual(Government.None, faction2.Government);
            Assert.AreEqual(Superpower.None, faction2.Allegiance);
            Assert.AreEqual(DateTime.MinValue, faction2.updatedAt);
            Assert.AreEqual(0, faction2.presences.Count);
        }