public void ShouldReturnOneLogEntryWhenGetEntriesForElement() { string elementId = "83f9cca1-8cf3-41c7-b55b-c80bbcca3dfa"; Utilities.LogEntry.LogEntry log = new Utilities.LogEntry.LogEntry { Application = "Register", User = "******", Description = "testing logging", ElementId = elementId }; List <Utilities.LogEntry.LogEntry> logEntries = new List <Utilities.LogEntry.LogEntry>(); logEntries.Add(log); var mockService = new Mock <ILogEntryService>(); mockService.Setup(l => l.GetEntriesForElement(elementId, 1)).Returns(Task.FromResult(logEntries)); mockService.Object.GetEntriesForElement(elementId, 1).Result.Should().HaveCount(1); }
public async Task ShouldReturnSuccessfullyWhenAddingToLog() { string logUrl = "http://api.dev.geonorge.no/endringslogg/"; Utilities.LogEntry.LogEntry log = new Utilities.LogEntry.LogEntry { Application = "Register", User = "******", Description = "testing logging", ElementId = "83f9cca1-8cf3-41c7-b55b-c80bbcca3dfa" }; const string content = @"{Application:""Register"", User:""demobruker"", Description:""testing logging"",ElementId : ""83f9cca1-8cf3-41c7-b55b-c80bbcca3dfa"" }"; var httpClient = CreateHttpClientFactory(HttpStatusCode.NoContent, content); LogEntryService service = new LogEntryService(logUrl, apiKey, httpClient); HttpStatusCode actualStatusCode = await service.AddLogEntry(log); var expectedStatusCode = HttpStatusCode.NoContent; Assert.Equal(expectedStatusCode, actualStatusCode); }