Пример #1
0
        public void ExtractDataToPositionMap()
        {
            using (var scope = TimeStub.CreateStubbedScope())
            {
                scope.OverrideNow(new DateTime(2014, 1, 1));

                MonthlyHeuristicsExtractor extractor = ConstructForFilePath(testFile);

                HeuristicsExtractionResult result = extractor.ExtractDayToPositionMap();

                Expect(result.Heuristics.Count, EqualTo(31));
                Expect(result.Heuristics.Keys.Min(), EqualTo(1));
                Expect(result.Heuristics.Keys.Max(), EqualTo(31));
                Expect(result.LogDate, EqualTo(new DateTime(2013, 3, 1, 0, 0, 0)));

                AssertData(result, 1, 0, 0);
                AssertData(result, 2, 0, 0);
                AssertData(result, 3, 0, 8);
                AssertData(result, 4, 449, 0);
                AssertData(result, 6, 449, 4);
                AssertData(result, 7, 665, 2);
                AssertData(result, 15, 775, 2);
                AssertData(result, 16, 890, 0);
                AssertData(result, 31, 890, 0);
            }
        }
Пример #2
0
            public async Task ReactsToCurrentServerChange()
            {
                //mocking current time to avoid test breaking precisely on midnight
                using (var scope = TimeStub.CreateStubbedScope())
                {
                    scope.OverrideNow(new DateTime(2015, 10, 06, 03, 10, 30));

                    var subscriber =
                        new Subscriber <CharacterDirectoriesChanged>(Fixture.WurmApiManager.InternalEventAggregator);
                    var serverChangeAwaiter = new EventAwaiter <PotentialServerChangeEventArgs>();

                    var playerdir = ClientMock.AddPlayer("Jack");
                    playerdir.SetConfigName("default");

                    // have to immediatelly create file, because during log monitor creation, existing file contents will not trigger events.
                    playerdir.Logs.CreateEventLogFile();
                    // have to wait until wurmapi picks up this folder
                    subscriber.WaitMessages(1);

                    var character = System.Get("Jack");
                    character.LogInOrCurrentServerPotentiallyChanged += serverChangeAwaiter.GetEventHandler();

                    Trace.WriteLine("writing first event");
                    playerdir.Logs.WriteEventLog("5 other players are online. You are on Exodus (50 totally in Wurm).");

                    serverChangeAwaiter.WaitUntilMatch(
                        list =>
                        list.Any(args => args.ServerName == new ServerName("Exodus")));

                    var server = await character.TryGetCurrentServerAsync();

                    Expect(server.ServerName, EqualTo(new ServerName("Exodus")));

                    Trace.WriteLine(
                        "writing second event");
                    playerdir.Logs.WriteEventLog(
                        "5 other players are online. You are on Deliverance (50 totally in Wurm).");

                    serverChangeAwaiter.WaitUntilMatch(
                        list =>
                        list.Any(args => args.ServerName == new ServerName("Deliverance")));

                    server = await character.TryGetCurrentServerAsync();

                    Expect(server.ServerName, EqualTo(new ServerName("Deliverance")));

                    Trace.WriteLine("writing third event");
                    playerdir.Logs.WriteEventLog(
                        "5 other players are online. You are on Deliverance (50 totally in Wurm).");

                    serverChangeAwaiter.WaitUntilMatch(
                        list =>
                        list.Any(args => args.ServerName == new ServerName("Deliverance")));

                    server = await character.TryGetCurrentServerAsync();

                    Expect(server.ServerName, EqualTo(new ServerName("Deliverance")));
                }
            }
        public void Init()
        {
            ClockScope = TimeStub.CreateStubbedScope();
            ClockScope.OverrideNow(new DateTime(2014, 12, 14, 17, 10, 0));
            ClockScope.OverrideNowOffset(new DateTime(2014, 12, 14, 17, 10, 0));

            ClientMock.PopulateFromZip(Path.Combine(TestPaksZippedDirFullPath, "WurmServerHistory-wurmdir.7z"));
        }
 public void Setup()
 {
     scope = TimeStub.CreateStubbedScope();
     scope.OverrideNowOffset(new DateTimeOffset(2014, 1, 1, 0, 0, 0, TimeSpan.Zero));
     scope.OverrideNow(new DateTime(2014, 1, 1, 0, 0, 0));
     //ClientMock.PopulateFromDir(Path.Combine(TestPaksDirFullPath, "logs-samples-forLogsMonitor"));
     ClientMock.PopulateFromZip(Path.Combine(TestPaksZippedDirFullPath, "logs-samples-forLogsMonitor.7z"));
     System = Fixture.WurmApiManager.LogsMonitor;
 }
Пример #5
0
 public void ExtractForEvent201412()
 {
     using (var scope = TimeStub.CreateStubbedScope())
     {
         scope.SetAllLocalTimes(new DateTime(2014, 12, 15));
         MonthlyHeuristicsExtractor extractor = ConstructForFilePath(fileEvent201412);
         var result = extractor.ExtractDayToPositionMap();
         AssertData(result, 14, 0, 18);
         AssertData(result, 15, 830, int.MaxValue);
     }
 }
Пример #6
0
 public GameEngineTests()
 {
     _timeStub            = new TimeStub();
     _playerManagerStub   = new PlayerManagerStub();
     _shotManagerStub     = new ShotManagerStub();
     _randomGeneratorStub = new RandomGeneratorStub();
     _gameEngine          = new GameEngine(NullLoggerFactory.Instance, _timeStub, _randomGeneratorStub)
     {
         PlayerManager = _playerManagerStub,
         ShotManager   = _shotManagerStub
     };
 }
Пример #7
0
        public void Setup()
        {
            ClientMock.PopulateFromZip(Path.Combine(TestPaksZippedDirFullPath, "WurmCharacterLogsTests-wurmdir.7z"));

            if (timeScope != null)
            {
                timeScope.Dispose();
                timeScope = null;
            }
            timeScope = TimeStub.CreateStubbedScope();
            timeScope.OverrideNow(new DateTime(2012, 09, 23, 23, 37, 13));
        }
Пример #8
0
        public virtual void Setup()
        {
            // gotcha: this will spam trace output with exceptions:
            Fixture.HttpWebRequestsMock.Arrange(requests => requests.GetResponseAsync(Arg.IsAny <string>()))
            .Throws <NotSupportedException>();

            HtmlWebRequestsDir =
                TempDirectoriesFactory.CreateByUnzippingFile(Path.Combine(TestPaksZippedDirFullPath,
                                                                          "WurmServerTests-wurmdir-webrequests.7z"));

            ClientMock.PopulateFromZip(Path.Combine(TestPaksZippedDirFullPath, "WurmServerTests-wurmdir.7z"));

            Timescope = TimeStub.CreateStubbedScope();
            Timescope.SetAllLocalTimes(MockedNow);
        }