Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: error when user tries to repost an appointment #11

Merged
merged 6 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Dataport.Terminfinder.BusinessLayer.Security;
using Dataport.Terminfinder.Repository;
using Dataport.Terminfinder.BusinessLayer.Security;
using Dataport.Terminfinder.BusinessObject;
using Dataport.Terminfinder.BusinessObject.Enum;
using Dataport.Terminfinder.Repository;
using Microsoft.Extensions.Logging;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
Expand All @@ -23,7 +20,7 @@ public class AppointmentBusinessLayerTests
"$2b$10$bKHadGFqngTajUrRAozjxeS3r5Mz6.nQwOBjT.kUcBeIF7FFYVt2W";

[TestInitialize]
public void Inilialize()
public void Initialize()
{
// fake logger
var mockLog = new Mock<ILogger<AppointmentBusinessLayer>>();
Expand Down Expand Up @@ -646,7 +643,7 @@ public void SetParticipantsForeignKeys_Okay()
Guid expectedParticipantId1 = new("CF1E5ABB-7D41-41AA-8DDC-0EB0319CD6B4");
Guid expectedParticipantId2 = new("D1C2DB5B-3FD8-4D8B-9A64-0C90298897D0");

List<Participant> fakeParcipiants = new()
List<Participant> fakeParticipants = new()
{
new Participant()
{
Expand Down Expand Up @@ -688,13 +685,13 @@ public void SetParticipantsForeignKeys_Okay()
var businessLayer = new AppointmentBusinessLayer(mockAppointmentRepo.Object, mockCustomerRepo.Object,
_bcryptWrapper, _logger);

businessLayer.SetParticipantsForeignKeys(fakeParcipiants, expectedCustomerId, expectedAppointmentId);
businessLayer.SetParticipantsForeignKeys(fakeParticipants, expectedCustomerId, expectedAppointmentId);

foreach (Participant participant in fakeParcipiants)
foreach (Participant participant in fakeParticipants)
{
Assert.AreEqual(expectedCustomerId, participant.CustomerId);
Assert.AreEqual(expectedAppointmentId, participant.AppointmentId);
Guid expectedParcipiantId = participant.ParticipantId;
Guid expectedParticipantId = participant.ParticipantId;

List<Voting> votings = participant.Votings.ToList();

Expand All @@ -704,7 +701,7 @@ public void SetParticipantsForeignKeys_Okay()

Assert.AreEqual(expectedCustomerId, voting.CustomerId);
Assert.AreEqual(expectedAppointmentId, voting.AppointmentId);
Assert.AreEqual(expectedParcipiantId, voting.ParticipantId);
Assert.AreEqual(expectedParticipantId, voting.ParticipantId);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using Dataport.Terminfinder.BusinessLayer.Security;
using Dataport.Terminfinder.BusinessLayer.Security;
using Microsoft.Extensions.Logging;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
Expand All @@ -16,7 +15,7 @@ public class BcryptWrapperTests
private readonly string SaltForUnittests = "$2b$10$bKHadGFqngTajUrRAozjxe";

[TestInitialize]
public void Inilialize()
public void Initialize()
{
// fake logger
logger = Mock.Of<ILogger<BcryptWrapper>>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class SaltGeneratorTests
private ILogger<SaltGenerator> logger;

[TestInitialize]
public void Inilialize()
public void Initialize()
{
// fake logger
logger = Mock.Of<ILogger<SaltGenerator>>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System.Collections.Generic;
using System.Linq;
using Dataport.Terminfinder.BusinessLayer.Security;
using Dataport.Terminfinder.Repository;
using Dataport.Terminfinder.BusinessLayer.Security;
using Dataport.Terminfinder.BusinessObject;
using Dataport.Terminfinder.BusinessObject.Enum;
using Dataport.Terminfinder.Common.Extension;
using Dataport.Terminfinder.Repository;

namespace Dataport.Terminfinder.BusinessLayer;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using Dataport.Terminfinder.BusinessObject;
using Dataport.Terminfinder.BusinessObject;
using Dataport.Terminfinder.BusinessObject.Enum;

namespace Dataport.Terminfinder.BusinessLayer;
Expand Down
3 changes: 1 addition & 2 deletions src/Dataport.Terminfinder.BusinessObject/Appointment.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using Dataport.Terminfinder.BusinessObject.Enum;
using Dataport.Terminfinder.BusinessObject.Enum;
using Dataport.Terminfinder.BusinessObject.JsonSerializer;
using Dataport.Terminfinder.BusinessObject.Validators;
using Dataport.Terminfinder.Common.Extension;
Expand Down
3 changes: 1 addition & 2 deletions src/Dataport.Terminfinder.BusinessObject/Participant.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using Dataport.Terminfinder.BusinessObject.JsonSerializer;
using Dataport.Terminfinder.BusinessObject.JsonSerializer;

namespace Dataport.Terminfinder.BusinessObject;

Expand Down
3 changes: 1 addition & 2 deletions src/Dataport.Terminfinder.BusinessObject/SuggestedDate.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using Dataport.Terminfinder.BusinessObject.JsonSerializer;
using Dataport.Terminfinder.BusinessObject.JsonSerializer;
using Dataport.Terminfinder.BusinessObject.Validators;
using JetBrains.Annotations;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using Dataport.Terminfinder.Common.Extension;
using Dataport.Terminfinder.Common.Extension;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections;
using System.Diagnostics.CodeAnalysis;

namespace Dataport.Terminfinder.Common.Tests.Extension;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Collections.Generic;
using System.Linq;

namespace Dataport.Terminfinder.Common.Extension;
namespace Dataport.Terminfinder.Common.Extension;

/// <summary>
/// Extension methods for interface IEnumerable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Extensions.Logging;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using System.Diagnostics.CodeAnalysis;

namespace Dataport.Terminfinder.Console.DeleteAppointments.Tool.Tests;

Expand All @@ -15,7 +13,7 @@ public class DeleteAppointmentsTests
private IDateTimeGeneratorService _dateTimeGeneratorServiceFake;

[TestInitialize]
public void Inilialize()
public void Initialize()
{
// fake logger
var mockLog = new Mock<ILogger<DeleteAppointmentsService>>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections.Generic;

namespace Dataport.Terminfinder.Console.DeleteAppointments.Tool;
namespace Dataport.Terminfinder.Console.DeleteAppointments.Tool;

/// <summary>
/// delete all appointments, if the oldest startdate (when enddate is null) or the oldest enddate older than x days
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using JetBrains.Annotations;
using JetBrains.Annotations;

namespace Dataport.Terminfinder.Console.DeleteAppointments.Tool;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System.Collections.Generic;
using System.Data;
using Npgsql;
using Npgsql;
using NpgsqlTypes;
using System.Data;
using System.Diagnostics.CodeAnalysis;

namespace Dataport.Terminfinder.Console.DeleteAppointments.Tool;

/// <inheritdoc cref="IRepository" />
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
[ExcludeFromCodeCoverage]
public class Repository : IRepository
{
private readonly ILogger _logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class AppConfigRepositoryTests
private ILogger<AppConfigRepository> _logger;

[TestInitialize]
public void Inilialize()
public void Initialize()
{
// fake logger
var mockLog = new Mock<ILogger<AppConfigRepository>>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class AppointmentRepositoryTests
private ILogger<AppointmentRepository> _logger;

[TestInitialize]
public void Inilialize()
public void Initialize()
{
// fake logger
var mockLog = new Mock<ILogger<AppointmentRepository>>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class CustomerRepositoryTests
private ILogger<CustomerRepository> _logger;

[TestInitialize]
public void Inilialize()
public void Initialize()
{
// fake logger
var mockLog = new Mock<ILogger<CustomerRepository>>();
Expand Down
9 changes: 4 additions & 5 deletions src/Dataport.Terminfinder.Repository/AppointmentRepository.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage;
using Dataport.Terminfinder.BusinessObject;
using Dataport.Terminfinder.BusinessObject;
using Dataport.Terminfinder.BusinessObject.Enum;
using Dataport.Terminfinder.Common.Extension;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Dataport.Terminfinder.Repository.Tests")]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using Dataport.Terminfinder.BusinessObject;
using Dataport.Terminfinder.BusinessObject;

namespace Dataport.Terminfinder.Repository;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class AdminControllerTests
private IRequestContext _requestContext;

[TestInitialize]
public void Inilialize()
public void Initialize()
{
// fake logger
var mockLog = new Mock<ILogger<AdminController>>();
Expand All @@ -26,7 +26,7 @@ public void Inilialize()
}

[TestMethod]
public void GetApppointment_Okay()
public void GetAppointment_Okay()
{
Guid expectedAppointmentId = new ("C1C2474B-488A-4ECF-94E8-47387BB715D5");
Guid expectedAdminId = new ("0EB748E2-32CF-49DE-8A63-14685AC943FF");
Expand Down Expand Up @@ -72,7 +72,7 @@ public void GetApppointment_Okay()
}

[TestMethod]
public void GetApppointment_AdminIdIsEmpty()
public void GetAppointment_AdminIdIsEmpty()
{
Guid expectedAppointmentId = new ("C1C2474B-488A-4ECF-94E8-47387BB715D5");
Guid expectedAdminId = new ("0EB748E2-32CF-49DE-8A63-14685AC943FF");
Expand Down Expand Up @@ -116,7 +116,7 @@ public void GetApppointment_AdminIdIsEmpty()
}

[TestMethod]
public void GetApppointment_NotFound()
public void GetAppointment_NotFound()
{
Guid expectedCustomerId = new ("BE1D657A-4D06-40DB-8443-D67BBB950EE7");

Expand All @@ -142,7 +142,7 @@ public void GetApppointment_NotFound()
}

[TestMethod]
public void GetApppointment_verificationFailed_Unauthorized()
public void GetAppointment_verificationFailed_Unauthorized()
{
const string expectedPassword = "P@$$w0rd";

Expand Down Expand Up @@ -196,7 +196,7 @@ public void GetApppointment_verificationFailed_Unauthorized()
}

[TestMethod]
public void GetApppointment_verificationSuccessful_okay()
public void GetAppointment_verificationSuccessful_okay()
{
const string expectedPassword = "P@$$w0rd";

Expand Down Expand Up @@ -394,7 +394,7 @@ public void SetStatus_appointmentStatusTypeStarted_Okay()
}

[TestMethod]
public void GetPasswordVerifcation_verificationSuccessful_True()
public void GetPasswordVerification_verificationSuccessful_True()
{
const string expectedPassword = "P@$$w0rd";

Expand Down Expand Up @@ -437,7 +437,7 @@ public void GetPasswordVerifcation_verificationSuccessful_True()

// Act
IActionResult httpResult =
controller.GetPasswordVerifcation(expectedCustomerId.ToString(), expectedAdminId.ToString());
controller.GetPasswordVerification(expectedCustomerId.ToString(), expectedAdminId.ToString());
OkObjectResult result = httpResult as OkObjectResult;
AppointmentPasswordVerificationResult verificationResult =
result?.Value as AppointmentPasswordVerificationResult;
Expand All @@ -448,7 +448,7 @@ public void GetPasswordVerifcation_verificationSuccessful_True()
}

[TestMethod]
public void GetPasswordVerifcation_verificationSuccessful_False()
public void GetPasswordVerification_verificationSuccessful_False()
{
const string expectedPassword = "P@$$w0rd";

Expand Down Expand Up @@ -491,7 +491,7 @@ public void GetPasswordVerifcation_verificationSuccessful_False()

// Act
IActionResult httpResult =
controller.GetPasswordVerifcation(expectedCustomerId.ToString(), expectedAdminId.ToString());
controller.GetPasswordVerification(expectedCustomerId.ToString(), expectedAdminId.ToString());
OkObjectResult result = httpResult as OkObjectResult;
AppointmentPasswordVerificationResult verificationResult =
result?.Value as AppointmentPasswordVerificationResult;
Expand All @@ -502,7 +502,7 @@ public void GetPasswordVerifcation_verificationSuccessful_False()
}

[TestMethod]
public void GetPasswordVerifcation_AppointmentNotProtected_True()
public void GetPasswordVerification_AppointmentNotProtected_True()
{
const string expectedPassword = "P@$$w0rd";

Expand Down Expand Up @@ -545,7 +545,7 @@ public void GetPasswordVerifcation_AppointmentNotProtected_True()

// Act
IActionResult httpResult =
controller.GetPasswordVerifcation(expectedCustomerId.ToString(), expectedAdminId.ToString());
controller.GetPasswordVerification(expectedCustomerId.ToString(), expectedAdminId.ToString());
OkObjectResult result = httpResult as OkObjectResult;
AppointmentPasswordVerificationResult verificationResult =
result?.Value as AppointmentPasswordVerificationResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class AppControllerTests
private IRequestContext _requestContext;

[TestInitialize]
public void Inilialize()
public void Initialize()
{
// fake logger
var mockLog = new Mock<ILogger<AppController>>();
Expand Down
Loading