From e81977815c6a7d29d5c8107d3cd435f14b221a25 Mon Sep 17 00:00:00 2001
From: Dave Roman <43916038+MrDave1999@users.noreply.github.com>
Date: Tue, 18 Apr 2023 11:00:15 -0500
Subject: [PATCH] Added the bot dialog tests to the integration test project
(#183)
---
DentallApp.sln | 8 ++++-
.../DentallApp.IntegrationTests.csproj | 29 +++++++++++++++++++
.../Chatbot/Dialogs/ActivityFactory.cs | 2 +-
.../Chatbot/Dialogs/BotServiceMockFactory.cs | 4 +--
.../Dialogs/RootDialogTests.Validation.cs | 6 +---
.../Chatbot/Dialogs/RootDialogTests.cs | 6 ++--
.../GlobalUsings.cs | 23 +++++++++++++++
.../DentallApp.UnitTests.csproj | 3 +-
tests/DentallApp.UnitTests/GlobalUsings.cs | 13 ---------
9 files changed, 67 insertions(+), 27 deletions(-)
create mode 100644 tests/DentallApp.IntegrationTests/DentallApp.IntegrationTests.csproj
rename tests/{DentallApp.UnitTests => DentallApp.IntegrationTests}/Features/Chatbot/Dialogs/ActivityFactory.cs (95%)
rename tests/{DentallApp.UnitTests => DentallApp.IntegrationTests}/Features/Chatbot/Dialogs/BotServiceMockFactory.cs (95%)
rename tests/{DentallApp.UnitTests => DentallApp.IntegrationTests}/Features/Chatbot/Dialogs/RootDialogTests.Validation.cs (95%)
rename tests/{DentallApp.UnitTests => DentallApp.IntegrationTests}/Features/Chatbot/Dialogs/RootDialogTests.cs (97%)
create mode 100644 tests/DentallApp.IntegrationTests/GlobalUsings.cs
diff --git a/DentallApp.sln b/DentallApp.sln
index 2a690e6c..d08487ff 100644
--- a/DentallApp.sln
+++ b/DentallApp.sln
@@ -5,7 +5,9 @@ VisualStudioVersion = 16.0.30114.105
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DentallApp", "src\DentallApp.csproj", "{E354A181-1E6C-4F76-8D99-96E5A6824FC1}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DentallApp.Tests", "tests\DentallApp.UnitTests\DentallApp.UnitTests.csproj", "{BE6318A1-900B-4E8E-8AAE-C391F881C844}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DentallApp.UnitTests", "tests\DentallApp.UnitTests\DentallApp.UnitTests.csproj", "{BE6318A1-900B-4E8E-8AAE-C391F881C844}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DentallApp.IntegrationTests", "tests\DentallApp.IntegrationTests\DentallApp.IntegrationTests.csproj", "{3897DDB9-5C4F-4664-94D7-756A5E673951}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -24,5 +26,9 @@ Global
{BE6318A1-900B-4E8E-8AAE-C391F881C844}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BE6318A1-900B-4E8E-8AAE-C391F881C844}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BE6318A1-900B-4E8E-8AAE-C391F881C844}.Release|Any CPU.Build.0 = Release|Any CPU
+ {3897DDB9-5C4F-4664-94D7-756A5E673951}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3897DDB9-5C4F-4664-94D7-756A5E673951}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3897DDB9-5C4F-4664-94D7-756A5E673951}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3897DDB9-5C4F-4664-94D7-756A5E673951}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
diff --git a/tests/DentallApp.IntegrationTests/DentallApp.IntegrationTests.csproj b/tests/DentallApp.IntegrationTests/DentallApp.IntegrationTests.csproj
new file mode 100644
index 00000000..9ffe64a5
--- /dev/null
+++ b/tests/DentallApp.IntegrationTests/DentallApp.IntegrationTests.csproj
@@ -0,0 +1,29 @@
+
+
+
+ net7.0
+ enable
+ disable
+
+ false
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/DentallApp.UnitTests/Features/Chatbot/Dialogs/ActivityFactory.cs b/tests/DentallApp.IntegrationTests/Features/Chatbot/Dialogs/ActivityFactory.cs
similarity index 95%
rename from tests/DentallApp.UnitTests/Features/Chatbot/Dialogs/ActivityFactory.cs
rename to tests/DentallApp.IntegrationTests/Features/Chatbot/Dialogs/ActivityFactory.cs
index f3627213..f67be65a 100644
--- a/tests/DentallApp.UnitTests/Features/Chatbot/Dialogs/ActivityFactory.cs
+++ b/tests/DentallApp.IntegrationTests/Features/Chatbot/Dialogs/ActivityFactory.cs
@@ -1,4 +1,4 @@
-namespace DentallApp.UnitTests.Features.Chatbot.Dialogs;
+namespace DentallApp.IntegrationTests.Features.Chatbot.Dialogs;
public static class ActivityFactory
{
diff --git a/tests/DentallApp.UnitTests/Features/Chatbot/Dialogs/BotServiceMockFactory.cs b/tests/DentallApp.IntegrationTests/Features/Chatbot/Dialogs/BotServiceMockFactory.cs
similarity index 95%
rename from tests/DentallApp.UnitTests/Features/Chatbot/Dialogs/BotServiceMockFactory.cs
rename to tests/DentallApp.IntegrationTests/Features/Chatbot/Dialogs/BotServiceMockFactory.cs
index 1e850c2b..9a7d375a 100644
--- a/tests/DentallApp.UnitTests/Features/Chatbot/Dialogs/BotServiceMockFactory.cs
+++ b/tests/DentallApp.IntegrationTests/Features/Chatbot/Dialogs/BotServiceMockFactory.cs
@@ -1,4 +1,4 @@
-namespace DentallApp.UnitTests.Features.Chatbot.Dialogs;
+namespace DentallApp.IntegrationTests.Features.Chatbot.Dialogs;
public static class BotServiceMockFactory
{
@@ -13,7 +13,7 @@ public static class BotServiceMockFactory
public const int PriceMin = 5;
public const int PriceMax = 10;
- public static IAppointmentBotService CreateMock()
+ public static IAppointmentBotService CreateBotServiceMock()
{
var botService = Mock.Create();
Mock.Arrange(() => botService.GetPatientsAsync(Arg.IsAny()))
diff --git a/tests/DentallApp.UnitTests/Features/Chatbot/Dialogs/RootDialogTests.Validation.cs b/tests/DentallApp.IntegrationTests/Features/Chatbot/Dialogs/RootDialogTests.Validation.cs
similarity index 95%
rename from tests/DentallApp.UnitTests/Features/Chatbot/Dialogs/RootDialogTests.Validation.cs
rename to tests/DentallApp.IntegrationTests/Features/Chatbot/Dialogs/RootDialogTests.Validation.cs
index b70fd91d..caab9430 100644
--- a/tests/DentallApp.UnitTests/Features/Chatbot/Dialogs/RootDialogTests.Validation.cs
+++ b/tests/DentallApp.IntegrationTests/Features/Chatbot/Dialogs/RootDialogTests.Validation.cs
@@ -1,4 +1,4 @@
-namespace DentallApp.UnitTests.Features.Chatbot.Dialogs;
+namespace DentallApp.IntegrationTests.Features.Chatbot.Dialogs;
public partial class RootDialogTests
{
@@ -26,7 +26,6 @@ public async Task Bot_WhenIncomingActivityHasValuePropertyWithNull_ShouldSendAnE
reply = await _testClient.SendActivityAsync(incomingActivity);
reply.Text.Should().Be(SelectDentistMessage);
- Environment.SetEnvironmentVariable(AppSettings.MaxDaysInCalendar, "60");
await _testClient.SendActivityAsync(CreateActivityWithSelectedDentistId());
_testClient.GetNextReply();
_testClient.GetNextReply();
@@ -72,7 +71,6 @@ public async Task Bot_WhenIncomingActivityHasValuePropertyWithoutJsonFormat_Shou
reply.Text.Should().Be(SelectDentistMessage);
_testClient.GetNextReply();
- Environment.SetEnvironmentVariable(AppSettings.MaxDaysInCalendar, "60");
await _testClient.SendActivityAsync(CreateActivityWithSelectedDentistId());
_testClient.GetNextReply();
_testClient.GetNextReply();
@@ -112,7 +110,6 @@ public async Task Bot_WhenThereAreNoHoursAvailable_ShouldSendAnErrorMessage()
await _testClient.SendActivityAsync(CreateActivityWithSelectedDentalServiceId());
_testClient.GetNextReply();
- Environment.SetEnvironmentVariable(AppSettings.MaxDaysInCalendar, "60");
await _testClient.SendActivityAsync(CreateActivityWithSelectedDentistId());
_testClient.GetNextReply();
_testClient.GetNextReply();
@@ -148,7 +145,6 @@ public async Task Bot_WhenDateAndTimeAppointmentIsNotAvailable_ShouldSendAnError
await _testClient.SendActivityAsync(CreateActivityWithSelectedDentalServiceId());
_testClient.GetNextReply();
- Environment.SetEnvironmentVariable(AppSettings.MaxDaysInCalendar, "60");
await _testClient.SendActivityAsync(CreateActivityWithSelectedDentistId());
_testClient.GetNextReply();
_testClient.GetNextReply();
diff --git a/tests/DentallApp.UnitTests/Features/Chatbot/Dialogs/RootDialogTests.cs b/tests/DentallApp.IntegrationTests/Features/Chatbot/Dialogs/RootDialogTests.cs
similarity index 97%
rename from tests/DentallApp.UnitTests/Features/Chatbot/Dialogs/RootDialogTests.cs
rename to tests/DentallApp.IntegrationTests/Features/Chatbot/Dialogs/RootDialogTests.cs
index 17073c97..a29e84e6 100644
--- a/tests/DentallApp.UnitTests/Features/Chatbot/Dialogs/RootDialogTests.cs
+++ b/tests/DentallApp.IntegrationTests/Features/Chatbot/Dialogs/RootDialogTests.cs
@@ -1,4 +1,4 @@
-namespace DentallApp.UnitTests.Features.Chatbot.Dialogs;
+namespace DentallApp.IntegrationTests.Features.Chatbot.Dialogs;
public partial class RootDialogTests
{
@@ -9,9 +9,10 @@ public partial class RootDialogTests
[SetUp]
public void TestInitialize()
{
- _botService = CreateMock();
+ _botService = CreateBotServiceMock();
_dateTimeProvider = Mock.Create();
_testClient = new(Channels.Webchat, new RootDialog(_botService, _dateTimeProvider));
+ Environment.SetEnvironmentVariable(AppSettings.MaxDaysInCalendar, "60");
}
[TestCase]
@@ -49,7 +50,6 @@ private async Task SendReplyWithChoiceSetAsync(string choiceType, Activity incom
private async Task SendReplyWithInputDateAsync(Activity incomingActivity)
{
- Environment.SetEnvironmentVariable(AppSettings.MaxDaysInCalendar, "60");
Mock.Arrange(() => _dateTimeProvider.Now).Returns(new DateTime(2023, 01, 01));
var reply = await _testClient.SendActivityAsync(incomingActivity);
diff --git a/tests/DentallApp.IntegrationTests/GlobalUsings.cs b/tests/DentallApp.IntegrationTests/GlobalUsings.cs
new file mode 100644
index 00000000..726f57ee
--- /dev/null
+++ b/tests/DentallApp.IntegrationTests/GlobalUsings.cs
@@ -0,0 +1,23 @@
+global using NUnit.Framework;
+global using FluentAssertions;
+global using Telerik.JustMock;
+global using AdaptiveCards;
+global using Microsoft.Bot.Connector;
+global using Microsoft.Bot.Builder.Testing;
+global using Microsoft.Bot.Schema;
+global using Newtonsoft.Json.Linq;
+
+global using static DentallApp.IntegrationTests.Features.Chatbot.Dialogs.BotServiceMockFactory;
+global using static DentallApp.IntegrationTests.Features.Chatbot.Dialogs.ActivityFactory;
+
+global using DentallApp.Features.Chatbot;
+global using DentallApp.Features.Chatbot.Models;
+global using DentallApp.Features.Chatbot.Dialogs;
+global using DentallApp.Features.Appointments.DTOs;
+global using DentallApp.Features.SpecificTreatments.DTOs;
+global using DentallApp.Features.AvailabilityHours.DTOs;
+
+global using DentallApp.Responses;
+global using DentallApp.Configuration;
+global using DentallApp.Helpers.DateTimeHelpers;
+global using static DentallApp.Constants.ResponseMessages;
\ No newline at end of file
diff --git a/tests/DentallApp.UnitTests/DentallApp.UnitTests.csproj b/tests/DentallApp.UnitTests/DentallApp.UnitTests.csproj
index 80ecbcd9..31b3be6a 100644
--- a/tests/DentallApp.UnitTests/DentallApp.UnitTests.csproj
+++ b/tests/DentallApp.UnitTests/DentallApp.UnitTests.csproj
@@ -14,8 +14,7 @@
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
+
diff --git a/tests/DentallApp.UnitTests/GlobalUsings.cs b/tests/DentallApp.UnitTests/GlobalUsings.cs
index c460ffa6..19d8f294 100644
--- a/tests/DentallApp.UnitTests/GlobalUsings.cs
+++ b/tests/DentallApp.UnitTests/GlobalUsings.cs
@@ -1,13 +1,9 @@
global using System.Collections;
global using NUnit.Framework;
global using FluentAssertions;
-global using AdaptiveCards;
-global using Microsoft.Bot.Connector;
global using Microsoft.Bot.Schema;
-global using Microsoft.Bot.Builder.Testing;
global using Telerik.JustMock;
global using System.Security.Claims;
-global using Newtonsoft.Json.Linq;
global using DotEnv.Core;
global using DentallApp.Features.AvailabilityHours;
@@ -19,15 +15,11 @@
global using DentallApp.Features.SecurityToken;
global using DentallApp.Features.Roles;
global using DentallApp.Features.Appointments;
-global using DentallApp.Features.Appointments.DTOs;
global using DentallApp.Features.EmployeeSchedules;
global using DentallApp.Features.EmployeeSchedules.DTOs;
global using DentallApp.Features.GeneralTreatments;
global using DentallApp.Features.GeneralTreatments.DTOs;
-global using DentallApp.Features.SpecificTreatments.DTOs;
global using DentallApp.Features.PublicHolidays.Offices;
-global using DentallApp.Features.Chatbot;
-global using DentallApp.Features.Chatbot.Dialogs;
global using DentallApp.Features.Chatbot.Models;
global using DentallApp.Features.Chatbot.DirectLine;
global using DentallApp.Features.Chatbot.DirectLine.Services;
@@ -37,9 +29,4 @@
global using DentallApp.Helpers.DateTimeHelpers;
global using DentallApp.Configuration;
global using DentallApp.DataAccess.Repositories;
-global using DentallApp.Responses;
global using static DentallApp.Constants.ResponseMessages;
-
-global using static DentallApp.UnitTests.Features.Chatbot.Dialogs.BotServiceMockFactory;
-global using static DentallApp.UnitTests.Features.Chatbot.Dialogs.ActivityFactory;
-