public async Task GetLastServerThrowsExceptionWhenFileDoesNotContainLastMPServerAsync()
        {
            MissingLastMPServer error = await Assert.ThrowsExceptionAsync <MissingLastMPServer>(
                () => ProfileParser.GetLastServer(filename, clock, source));

            Assert.AreEqual("Unable to find last MP server in DayZ profile", error.Message);
        }
        public async Task GetLastServerReturnsLastMPServerValue()
        {
            File.WriteAllText(
                filename,
                "something=\"some-value\";\n" +
                "lastMPServer=\"87.65.43.21:1234\";\n" +
                "otherThing=\"other-value\";\n");

            Server server = await ProfileParser.GetLastServer(filename, clock, source);

            Assert.AreEqual("87.65.43.21", server.Host);
            Assert.AreEqual(1234, server.Port);
        }
        public async Task GetLastServerRetriesWhenUnableToReadProfileDueToAccessViolation()
        {
            File.WriteAllText(filename, "lastMPServer=\"87.65.43.21:1234\";\n");

            using (FileStream writeStream = File.OpenWrite(filename))
            {
                clock.SetDelayCompleted();
                clock.DelayCalled = (source, args) => writeStream.Close();

                Server server = await ProfileParser.GetLastServer(filename, clock, source);

                Assert.AreEqual("87.65.43.21", server.Host);
                Assert.AreEqual(1234, server.Port);
            }
        }
Exemplo n.º 4
0
        public async Task GetLastServerReturnsLastMPServerValue()
        {
            using (FileStream fs = File.OpenWrite(filename))
            {
                fs.Write(Encoding.UTF8.GetBytes(
                             "something=\"some-value\";\n" +
                             "lastMPServer=\"87.65.43.21:1234\";\n" +
                             "otherThing=\"other-value\";\n"));
            }

            Server server = await ProfileParser.GetLastServer(filename);

            Assert.AreEqual("87.65.43.21", server.Host);
            Assert.AreEqual(1234, server.Port);
        }