public void SavingAnItemWorks(string data, string topic) { // Arrange using (var context = new AuditLogContext(_options)) { var repository = new AuditLogItemRepository(context); var item = new AuditLogItem { Data = data, Topic = topic, Id = Guid.NewGuid().ToString() }; // Act repository.Save(item); } // Assert using var controlContext = new AuditLogContext(_options); var resultData = controlContext.AuditLogItems.ToArray(); Assert.AreEqual(1, resultData.Length); var firstItem = resultData.First(); Assert.AreEqual(data, firstItem.Data); Assert.AreEqual(topic, firstItem.Topic); }
public void RetrievingItemsFromSpecificTimePeriodWorks(long fromTimeStamp, long toTimeStamp, int expectedAmount) { // Arrange InjectData(_dummyData); using var context = new AuditLogContext(_options); var repository = new AuditLogItemRepository(context); var criteria = new AuditLogItemCriteria { FromTimeStamp = fromTimeStamp, ToTimeStamp = toTimeStamp }; // Act AuditLogItem[] results = repository.FindBy(criteria).ToArray(); // Assert Assert.AreEqual(expectedAmount, results.Length); }
public void RetrievingItemsWithTypeWorks(string types, int expectedAmount) { string[] typeNames = types.Split(','); // Arrange InjectData(_dummyData); using var context = new AuditLogContext(_options); var repository = new AuditLogItemRepository(context); var criteria = new AuditLogItemCriteria { Types = typeNames, ToTimeStamp = 100 }; // Act AuditLogItem[] results = repository.FindBy(criteria).ToArray(); // Assert Assert.AreEqual(expectedAmount, results.Length); }
public void AllowingMetaEventsFiltersEvents(bool allowMeta, int expectedAmount) { // Arrange InjectData(_dummyData); using var context = new AuditLogContext(_options); var repository = new AuditLogItemRepository(context); var criteria = new AuditLogItemCriteria { AllowMetaEvents = allowMeta, ToTimeStamp = 600, FromTimeStamp = 0 }; // Act AuditLogItem[] results = repository.FindBy(criteria).ToArray(); // Assert Assert.AreEqual(expectedAmount, results.Length); }