Пример #1
0
        /// <summary>Test stub for AdjustExpenditure(String, Double, Double, Double, Double, Double)</summary>

        public void AdjustExpenditureTest(
            TestClient TestClient,
            string fiefID,
            double newTax,
            double newOff,
            double newGarr,
            double newKeep,
            double newInfra
            )
        {
            TestClient.AdjustExpenditure(fiefID, newTax, newOff, newGarr, newKeep, newInfra);

            Client client = null;

            if (!ValidClientState(TestClient, out client))
            {
                Task <string> ReplyTask = TestClient.GetServerMessage();
                ReplyTask.Wait();
                string reply = ReplyTask.Result;
                Assert.AreEqual("Not logged in- Disconnecting", reply);
                return;
            }
            // If not a valid fief, expect to fail
            if (string.IsNullOrWhiteSpace(fiefID) || !Globals_Game.fiefKeys.Contains(fiefID))
            {
                Console.Write("not a fief Id ");
                Task <ProtoMessage> ReplyTask = TestClient.GetReply();
                ReplyTask.Wait();
                ProtoMessage reply = ReplyTask.Result;
                Assert.AreEqual(reply.ResponseType, DisplayMessages.ErrorGenericFiefUnidentified);
            }
            else
            {
                Task <ProtoMessage> ReplyTask = TestClient.GetReply();
                ReplyTask.Wait();
                ProtoMessage reply = ReplyTask.Result;
                // If not fief owner expect unauthorised
                Fief fief = null;
                Globals_Game.fiefMasterList.TryGetValue(fiefID, out fief);
                if (fief.owner != client.myPlayerCharacter)
                {
                    Assert.AreEqual(reply.ResponseType, DisplayMessages.ErrorGenericUnauthorised);
                }
                // If numbers invalid expect an invalid exception
                else if (newTax < 0 || newOff < 0 || newGarr < 0 || newKeep < 0 || newInfra < 0)
                {
                    Assert.AreEqual(reply.ResponseType, DisplayMessages.ErrorGenericMessageInvalid);
                }
                else
                {
                    if (reply.GetType() == typeof(ProtoFief))
                    {
                        Assert.AreEqual(DisplayMessages.FiefExpenditureAdjusted, reply.ResponseType);
                    }
                    else
                    {
                        Assert.AreEqual(DisplayMessages.FiefExpenditureAdjustment, reply.ResponseType);
                    }
                }
            }
        }