From 95dfef62196fe1a0c03686f26c5d33172eda9388 Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Thu, 12 Sep 2024 13:05:58 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B0=20=D0=B0?= =?UTF-8?q?=D0=B2=D1=82=D0=BE=D1=82=D0=B5=D1=81=D1=82=D0=B0=20=D0=BF=D0=BE?= =?UTF-8?q?=20=D1=80=D0=B5=D0=B7=D1=83=D0=BB=D1=8C=D1=82=D0=B0=D1=82=D0=B0?= =?UTF-8?q?=D0=BC=20=D1=80=D0=B5=D0=B2=D1=8C=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/MessageServiceTest.cs | 56 ++++++------------- 1 file changed, 17 insertions(+), 39 deletions(-) diff --git a/AsbCloudInfrastructure.Tests/Services/MessageServiceTest.cs b/AsbCloudInfrastructure.Tests/Services/MessageServiceTest.cs index f3bc4bf3..ae7b6691 100644 --- a/AsbCloudInfrastructure.Tests/Services/MessageServiceTest.cs +++ b/AsbCloudInfrastructure.Tests/Services/MessageServiceTest.cs @@ -245,47 +245,25 @@ public class MessageServiceTest Assert.Equal(6, result.Count()); - var messageStat_1_1 = result - .Where(x => x.IdWell == 1) - .Where(x => x.IdCategory == 1) - .Where(x => x.MessageTemplate == "Шаблон сообщения 1 категории 1") - .Single(); - Assert.Equal(3, messageStat_1_1.MessagesCount); + AssertStatByEvent(result, 1, events[0], 3); + AssertStatByEvent(result, 1, events[1], 3); + AssertStatByEvent(result, 1, events[2], 3); + AssertStatByEvent(result, 1, events[3], 2); + AssertStatByEvent(result, 1, events[4], 2); + AssertStatByEvent(result, 2, events[5], 3); + } - var messageStat_1_2 = result - .Where(x => x.IdWell == 1) - .Where(x => x.IdCategory == 1) - .Where(x => x.MessageTemplate == "Шаблон сообщения 2 категории 1") - .Single(); - Assert.Equal(3, messageStat_1_2.MessagesCount); + private void AssertStatByEvent(IEnumerable result, int idWell, TelemetryEventDto eventDto, int count) + { + var eventStats = result + .Where(x => x.IdWell == idWell) + .Where(x => x.IdCategory == eventDto.IdCategory) + .Where(x => x.MessageTemplate == eventDto.MessageTemplate) + .ToArray(); - var messageStat_1_3 = result - .Where(x => x.IdWell == 1) - .Where(x => x.IdCategory == 1) - .Where(x => x.MessageTemplate == "Шаблон сообщения 3 категории 1") - .Single(); - Assert.Equal(3, messageStat_1_3.MessagesCount); - - var messageStat_2_2 = result - .Where(x => x.IdWell == 1) - .Where(x => x.IdCategory == 2) - .Where(x => x.MessageTemplate == "Шаблон сообщения 2 категории 2") - .Single(); - Assert.Equal(2, messageStat_2_2.MessagesCount); - - var messageStat_2_1 = result - .Where(x => x.IdWell == 1) - .Where(x => x.IdCategory == 2) - .Where(x => x.MessageTemplate == "Шаблон сообщения 1 категории 2") - .Single(); - Assert.Equal(2, messageStat_2_1.MessagesCount); - - var messageStat_3_1 = result - .Where(x => x.IdWell == 2) - .Where(x => x.IdCategory == 3) - .Where(x => x.MessageTemplate == "Шаблон сообщения 1 категории 3") - .Single(); - Assert.Equal(3, messageStat_3_1.MessagesCount); + Assert.Single(eventStats); + var eventStat = eventStats.First(); + Assert.Equal(count, eventStat.MessagesCount); }