コード例 #1
0
        public async Task RecordNumber_Does_Not_Grow_Over_Max_Val()
        {
            await _memoryDistributedCache.SetStringAsync(rootKey, JsonConvert.SerializeObject(MachineHistoryPage.Empty("name")), _token);

            for (var i = 0; i < StorageConfiguration.NumberOfRecordsPerMachine * 2; i++)
            {
                var recordNumber = await _storage.AddRecordAsync(new IpRecord(), _token);

                recordNumber.ShouldBe(i % StorageConfiguration.NumberOfRecordsPerMachine);
            }
        }
コード例 #2
0
        public async Task Records_Returned_In_ReversedOrder()
        {
            await _memoryDistributedCache.SetStringAsync(rootKey, JsonConvert.SerializeObject(MachineHistoryPage.Empty("name")), _token);

            for (var i = 0; i < StorageConfiguration.NumberOfRecordsPerMachine; i++)
            {
                _ = await _storage.AddRecordAsync(new IpRecord {
                    CurrentIP = i.ToString()
                }, _token);
            }

            var records = await _storage.GetHistoryAsync(_token);

            using var enumerator = records.GetEnumerator();
            enumerator.MoveNext();
            for (var i = 0; i < StorageConfiguration.NumberOfRecordsPerMachine; i++)
            {
                var next = enumerator.Current;
                next.ShouldSatisfyAllConditions(
                    () => next.ShouldNotBeNull(),
                    () => next.CurrentIP.ShouldBe((StorageConfiguration.NumberOfRecordsPerMachine - i - 1).ToString())
                    );
                enumerator.MoveNext();
            }
        }
コード例 #3
0
        public async Task RecordNumber_Increased()
        {
            await _memoryDistributedCache.SetStringAsync(rootKey, JsonConvert.SerializeObject(MachineHistoryPage.Empty("name")), _token);

            var recordNumber = await _storage.AddRecordAsync(new IpRecord(), _token);

            recordNumber.ShouldBe(0);
        }