public async Task GetRecordsListByText_ShouldReplacePlaceholdereByHostAndPort_InCogitationsText() { var context = CreateContext(); context.SoftDeleting = true; Create_20Records(context, GetNumberList(20, "SearchText_"), GetDatesList(20)); await Add3CogitationsForEachRecord(context); var recSearchByTextSvc = GetRecordsSearchTextService(context); var hostAndPortService = new HostAndPortStub(); // add links var(cog1, cog2) = await For2RecordsAddLinkToCogitations(context, hostAndPortService); var list = await recSearchByTextSvc.GetRecordsList(new RecordsTextFilter { SearchText = "SearchText" }); var allCogitations = list.SelectMany(r => r.Cogitations).ToList(); var c1 = allCogitations.SingleOrDefault(c => c.Id == cog1); c1?.Text.Should().NotContain(hostAndPortService.GetHostAndPortPlaceholder()); c1?.Text.Should().Contain(hostAndPortService.GetHostAndPort()); var c2 = list.SingleOrDefault(r => r.Id == cog2); c2?.Text.Should().NotContain(hostAndPortService.GetHostAndPortPlaceholder()); c2?.Text.Should().Contain(hostAndPortService.GetHostAndPort()); }
public async Task AddDiaryRecord_ShouldReplaceHostAndPortByPlaceholder() { var context = CreateContext(); var svc = GetRecordsService(context); var hpSvc = new HostAndPortStub(); var text = $@"New text with link {hpSvc.GetHostAndPort()}/index and another link {hpSvc.GetHostAndPort()}/images/12345678"; var id = await svc.AddRecord(DateOnly.FromDateTime(DateTime.UtcNow), text, text); var rec = await context.Records.SingleOrDefaultAsync(r => r.Id == id); rec.Name.Should().NotContain(hpSvc.GetHostAndPort()); rec.Text.Should().NotContain(hpSvc.GetHostAndPort()); rec.Name.Should().Contain(hpSvc.GetHostAndPortPlaceholder(), Exactly.Twice()); rec.Text.Should().Contain(hpSvc.GetHostAndPortPlaceholder(), Exactly.Twice()); }
public async Task FetchRecordById_ShouldReplacePlaceholderByHostAndPort() { var context = CreateContext(); var svc = GetRecordsService(context); var rec = GetTestRecord(); var hpSvc = new HostAndPortStub(); var text = $@"New text with link {hpSvc.GetHostAndPortPlaceholder()}/index and another link {hpSvc.GetHostAndPortPlaceholder()}/images/12345678"; rec.Name = text; rec.Text = text; context.Records.Add(rec); await context.SaveChangesAsync(); var savedRec = await svc.FetchRecordById(rec.Id); savedRec.Name.Should().NotContain(hpSvc.GetHostAndPortPlaceholder()); savedRec.Text.Should().NotContain(hpSvc.GetHostAndPortPlaceholder()); savedRec.Name.Should().Contain(hpSvc.GetHostAndPort(), Exactly.Twice()); savedRec.Text.Should().Contain(hpSvc.GetHostAndPort(), Exactly.Twice()); }
public async Task GetAllDates_ShouldReplacePlaceholdereByHostAndPort_InRecordText() { var context = CreateContext(); await AddTestData(context); var datesService = GetDatesService(10, context); var hostAndPortService = new HostAndPortStub(); var list = await datesService.GetAllDates(DateOnly.FromDateTime(DateTime.UtcNow)); var r1 = list[2]; r1?.Text.Should().NotContain(hostAndPortService.GetHostAndPortPlaceholder()); r1?.Text.Should().Contain(hostAndPortService.GetHostAndPort()); var r2 = list[5]; r2?.Text.Should().NotContain(hostAndPortService.GetHostAndPortPlaceholder()); r2?.Text.Should().Contain(hostAndPortService.GetHostAndPort()); }
public async Task FetchRecordById_ShouldReplacePlaceholderByHostAndPort_InCogitations() { var context = CreateContext(); var svc = GetRecordsService(context); var recId = Create_Record(context); var hpSvc = new HostAndPortStub(); var text = $@"New text with link {hpSvc.GetHostAndPortPlaceholder()}/index and another link {hpSvc.GetHostAndPortPlaceholder()}/images/12345678"; var cogitationsList = Enumerable.Range(1, 3) .Select(i => new Cogitation { Id = Guid.NewGuid(), RecordId = recId, Date = DateTime.UtcNow, Text = text }).ToList(); context.Cogitations.AddRange(cogitationsList); await context.SaveChangesAsync(); var savedRec = await svc.FetchRecordById(recId); foreach (var c in savedRec.Cogitations) { c.Text.Should().NotContain(hpSvc.GetHostAndPortPlaceholder()); c.Text.Should().Contain(hpSvc.GetHostAndPort(), Exactly.Twice()); } }
public async Task GetRecordsListByText_ShouldReplacePlaceholdereByHostAndPort_InRecordText() { var context = CreateContext(); context.SoftDeleting = true; Create_20Records(context, GetNumberList(20, "SearchText_"), GetDatesList(20)); var recSearchByTextSvc = GetRecordsSearchTextService(context); var hostAndPortService = new HostAndPortStub(); // add links var(rec1, rec2) = await For2RecordsAddLinkToText(context, hostAndPortService); var list = await recSearchByTextSvc.GetRecordsList(new RecordsTextFilter { SearchText = "SearchText" }); var r1 = list.SingleOrDefault(r => r.Id == rec1); r1?.Text.Should().NotContain(hostAndPortService.GetHostAndPortPlaceholder()); r1?.Text.Should().Contain(hostAndPortService.GetHostAndPort()); var r2 = list.SingleOrDefault(r => r.Id == rec2); r2?.Text.Should().NotContain(hostAndPortService.GetHostAndPortPlaceholder()); r2?.Text.Should().Contain(hostAndPortService.GetHostAndPort()); }
public async Task GetRecordsList_ShouldReplacePlaceholdereByHostAndPort_InRecordName() { var context = CreateContext(); context.SoftDeleting = true; Create_20Records(context, GetNumberList(20), GetDatesList(20)); var svc = GetRecordsSearchService(context); var hostAndPortService = new HostAndPortStub(); // add links var(rec1, rec2) = await For2RecordsAddLinkToName(context, hostAndPortService); var list = await svc.GetRecordsList(RecordsFilter.Empty); var r1 = list.SingleOrDefault(r => r.Id == rec1); r1?.Name.Should().NotContain(hostAndPortService.GetHostAndPortPlaceholder()); r1?.Name.Should().Contain(hostAndPortService.GetHostAndPort()); var r2 = list.SingleOrDefault(r => r.Id == rec2); r2?.Name.Should().NotContain(hostAndPortService.GetHostAndPortPlaceholder()); r2?.Name.Should().Contain(hostAndPortService.GetHostAndPort()); }
public async Task AddCogitation_ShouldReplaceHostAndPortByPlaceholdere() { var context = CreateContext(); var svc = GetRecordsService(context); var recId = Create_Record(context); var hpSvc = new HostAndPortStub(); var text = $@"New text with link {hpSvc.GetHostAndPort()}/index and another link {hpSvc.GetHostAndPort()}/images/12345678"; var cogId = await svc.AddCogitation(recId, text); var cog = await context.Cogitations.FindAsync(cogId); cog.Text.Should().NotContain(hpSvc.GetHostAndPort()); cog.Text.Should().Contain(hpSvc.GetHostAndPortPlaceholder(), Exactly.Twice()); }
public async Task UpdateCogitationText_ShouldReplaceHostAndPortByPlaceholdere() { var context = CreateContext(); var svc = GetRecordsService(context); var recId = Create_Record(context); var cId = Guid.NewGuid(); var cDate = DateTime.UtcNow; var cText = "Some Text 81237912y0r9182ny"; var hpSvc = new HostAndPortStub(); var newText = $@"New text with link {hpSvc.GetHostAndPort()}/index and another link {hpSvc.GetHostAndPort()}/images/12345678"; context.Cogitations.Add(new Cogitation { Id = cId, Date = cDate, RecordId = recId, Text = cText }); await context.SaveChangesAsync(); await svc.UpdateCogitationText(cId, newText); var cog = await context.Cogitations.FindAsync(cId); cog.Text.Should().NotContain(hpSvc.GetHostAndPort()); cog.Text.Should().Contain(hpSvc.GetHostAndPortPlaceholder(), Exactly.Twice()); }