forked from slavaxom9k/PIBD-23_Fomichev_V.S._MagicCarpet
тесты и не только
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using MagicCarpetContracts.DataModels;
|
||||
using MagicCarpetContracts.Infrastructure;
|
||||
using MagicCarpetContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace MagicCarpetContracts.DataModels;
|
||||
public class AgencyDataModel(string id, TourType tourType, int count, List<TourAgencyDataModel> tours) : IValidation
|
||||
{
|
||||
public string Id { get; private set; } = id;
|
||||
public TourType Type { get; private set; } = tourType;
|
||||
public TourType TourType { get; private set; } = tourType;
|
||||
public int Count { get; private set; } = count;
|
||||
public List<TourAgencyDataModel> Tours { get; private set; } = tours;
|
||||
|
||||
@@ -23,7 +23,7 @@ public class AgencyDataModel(string id, TourType tourType, int count, List<TourA
|
||||
throw new ValidationException("Field Id is empty");
|
||||
if (!Id.IsGuid())
|
||||
throw new ValidationException("The value in the field Id is not a unique identifier");
|
||||
if (Type == TourType.None)
|
||||
if (TourType == TourType.None)
|
||||
throw new ValidationException("Field Type is empty");
|
||||
if (Count <= 0)
|
||||
throw new ValidationException("Field Count is less than or equal to 0");
|
||||
|
||||
@@ -11,11 +11,11 @@ using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace MagicCarpetContracts.DataModels;
|
||||
|
||||
public class SuppliesDataModel(string id, TourType tourType, DateTime date, int count, List<TourSuppliesDataModel> tours) : IValidation
|
||||
public class SuppliesDataModel(string id, TourType tourType, DateTime productuionDate, int count, List<TourSuppliesDataModel> tours) : IValidation
|
||||
{
|
||||
public string Id { get; private set; } = id;
|
||||
public TourType TourType { get; private set; } = tourType;
|
||||
public DateTime ProductuionDate { get; private set; } = date;
|
||||
public DateTime ProductuionDate { get; private set; } = productuionDate;
|
||||
public int Count { get; private set; } = count;
|
||||
public List<TourSuppliesDataModel> Tours { get; private set; } = tours;
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ namespace MagicCarpetContracts.Infrastructure;
|
||||
|
||||
public class OperationResponse
|
||||
{
|
||||
protected HttpStatusCode StatusCode { get; set; }
|
||||
public HttpStatusCode StatusCode { get; set; }
|
||||
|
||||
protected object? Result { get; set; }
|
||||
public object? Result { get; set; }
|
||||
|
||||
public IActionResult GetResponse(HttpRequest request, HttpResponse response)
|
||||
{
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
using MagicCarpetContracts.Enums;
|
||||
using MagicCarpetContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.DataModels;
|
||||
namespace MagicCarpetContracts.ViewModels;
|
||||
|
||||
public class AgencyViewModel
|
||||
{
|
||||
public required string Id { get; set; }
|
||||
public required TourType TourType { get; set; }
|
||||
public required int Count { get; set; }
|
||||
public required List<TourAgencyViewModel> Components { get; set; }
|
||||
public required List<TourAgencyViewModel> Tours { get; set; }
|
||||
}
|
||||
@@ -114,7 +114,7 @@ public class AgencyStorageContract : IAgencyStorageContract
|
||||
foreach (SaleTourDataModel sale_tour in saleDataModel.Tours)
|
||||
{
|
||||
var tour = _dbContext.Tours.FirstOrDefault(x => x.Id == sale_tour.TourId);
|
||||
var agency = _dbContext.Agencies.FirstOrDefault(x => x.Type == tour.TourType && x.Count >= sale_tour.Count);
|
||||
var agency = _dbContext.Agencies.FirstOrDefault(x => x.TourType == tour.TourType && x.Count >= sale_tour.Count);
|
||||
|
||||
if (agency == null)
|
||||
{
|
||||
|
||||
@@ -10,10 +10,11 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetDatabase.Models;
|
||||
|
||||
[AutoMap(typeof(AgencyDataModel), ReverseMap = true)]
|
||||
public class Agency
|
||||
{
|
||||
public required string Id { get; set; }
|
||||
public required TourType Type { get; set; }
|
||||
public required TourType TourType { get; set; }
|
||||
public required int Count { get; set; }
|
||||
|
||||
[ForeignKey("AgencyId")]
|
||||
|
||||
@@ -398,8 +398,8 @@ internal class SaleBusinessLogicContractTests
|
||||
{
|
||||
//Arrange
|
||||
var flag = false;
|
||||
var record = new SaleDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 10, DiscountType.None, 10,
|
||||
false, [new SaleTourDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 5)]);
|
||||
var record = new SaleDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), DiscountType.None,
|
||||
false, [new SaleTourDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 5, 1.2)]);
|
||||
_agencyStorageContract.Setup(x => x.CheckComponents(It.IsAny<SaleDataModel>())).Returns(true);
|
||||
_saleStorageContract.Setup(x => x.AddElement(It.IsAny<SaleDataModel>()))
|
||||
.Callback((SaleDataModel x) =>
|
||||
@@ -427,7 +427,7 @@ internal class SaleBusinessLogicContractTests
|
||||
_saleStorageContract.Setup(x => x.AddElement(It.IsAny<SaleDataModel>())).Throws(new ElementExistsException("Data", "Data"));
|
||||
//Act&Assert
|
||||
Assert.That(() => _saleBusinessLogicContract.InsertSale(new(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(),
|
||||
Guid.NewGuid().ToString(), 10, DiscountType.None, 10, false, [new SaleTourDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 5)])), Throws.TypeOf<ElementExistsException>());
|
||||
Guid.NewGuid().ToString(), DiscountType.None, false, [new SaleTourDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 5, 1.2)])), Throws.TypeOf<ElementExistsException>());
|
||||
_saleStorageContract.Verify(x => x.AddElement(It.IsAny<SaleDataModel>()), Times.Once);
|
||||
_agencyStorageContract.Verify(x => x.CheckComponents(It.IsAny<SaleDataModel>()), Times.Once);
|
||||
}
|
||||
@@ -456,7 +456,7 @@ internal class SaleBusinessLogicContractTests
|
||||
_saleStorageContract.Setup(x => x.AddElement(It.IsAny<SaleDataModel>())).Throws(new StorageException(new InvalidOperationException()));
|
||||
//Act&Assert
|
||||
Assert.That(() => _saleBusinessLogicContract.InsertSale(new(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(),
|
||||
Guid.NewGuid().ToString(), 10, DiscountType.None, 10, false, [new SaleTourDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 5)])), Throws.TypeOf<StorageException>());
|
||||
Guid.NewGuid().ToString(), DiscountType.None, false, [new SaleTourDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 5, 1.2)])), Throws.TypeOf<StorageException>());
|
||||
_agencyStorageContract.Verify(x => x.CheckComponents(It.IsAny<SaleDataModel>()), Times.Once);
|
||||
_saleStorageContract.Verify(x => x.AddElement(It.IsAny<SaleDataModel>()), Times.Once);
|
||||
}
|
||||
@@ -466,9 +466,8 @@ internal class SaleBusinessLogicContractTests
|
||||
{
|
||||
//Arrange
|
||||
_agencyStorageContract.Setup(x => x.CheckComponents(It.IsAny<SaleDataModel>())).Returns(false);
|
||||
Assert.That(() => _saleBusinessLogicContract.InsertSale(new SaleDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(),
|
||||
Guid.NewGuid().ToString(), 10, DiscountType.None, 10, false,
|
||||
[new SaleTourDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 5)])), Throws.TypeOf<InsufficientException>());
|
||||
Assert.That(() => _saleBusinessLogicContract.InsertSale(new(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(),
|
||||
Guid.NewGuid().ToString(), DiscountType.None, false, [new SaleTourDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 5, 1.2)])), Throws.TypeOf<InsufficientException>());
|
||||
//Act&Assert
|
||||
_agencyStorageContract.Verify(x => x.CheckComponents(It.IsAny<SaleDataModel>()), Times.Once);
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ internal class TourBusinessLogicContractTests
|
||||
_tourStorageContract.Setup(x => x.AddElement(It.IsAny<TourDataModel>()))
|
||||
.Callback((TourDataModel x) =>
|
||||
{
|
||||
flag = x.Id == record.Id && x.TourName == record.TourName && x.TourCountry == record.TourCountry
|
||||
flag = x.Id == record.Id && x.TourName == record.TourName && x.TourCountry == record.TourCountry
|
||||
&& x.Price == record.Price && x.TourType == record.TourType;
|
||||
});
|
||||
//Act
|
||||
@@ -295,7 +295,7 @@ internal class TourBusinessLogicContractTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InsertFurniture_InsufficientError_ThrowException_Test()
|
||||
public void InsertTour_InsufficientError_ThrowException_Test()
|
||||
{
|
||||
//Arrange
|
||||
Assert.That(() => _tourBusinessLogicContract.InsertTour(new TourDataModel(Guid.NewGuid().ToString(), "name", "country", 10, TourType.Ski)),Throws.TypeOf<InsufficientException>());
|
||||
|
||||
@@ -66,7 +66,7 @@ internal class AgencyDataModelTests
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(model.Id, Is.EqualTo(id));
|
||||
Assert.That(model.Type, Is.EqualTo(type));
|
||||
Assert.That(model.TourType, Is.EqualTo(type));
|
||||
Assert.That(model.Count, Is.EqualTo(count));
|
||||
Assert.That(model.Tours, Is.EqualTo(tours));
|
||||
});
|
||||
|
||||
@@ -77,17 +77,17 @@ internal static class MagicCarpetDbContextExtensions
|
||||
|
||||
public static Agency InsertAgencyToDatabaseAndReturn(this MagicCarpetDbContext dbContext, string? id = null, TourType tourType = TourType.Beach, int count = 20, List<(string, int)>? tours = null)
|
||||
{
|
||||
var warehouse = new Agency() { Id = id ?? Guid.NewGuid().ToString(), Type = tourType, Count = count, Tours = [] };
|
||||
var agency = new Agency() { Id = id ?? Guid.NewGuid().ToString(), TourType = tourType, Count = count, Tours = [] };
|
||||
if (tours is not null)
|
||||
{
|
||||
foreach (var elem in tours)
|
||||
{
|
||||
warehouse.Tours.Add(new TourAgency { AgencyId = warehouse.Id, TourId = elem.Item1, Count = elem.Item2 });
|
||||
agency.Tours.Add(new TourAgency { AgencyId = agency.Id, TourId = elem.Item1, Count = elem.Item2 });
|
||||
}
|
||||
}
|
||||
dbContext.Agencies.Add(warehouse);
|
||||
dbContext.Agencies.Add(agency);
|
||||
dbContext.SaveChanges();
|
||||
return warehouse;
|
||||
return agency;
|
||||
}
|
||||
|
||||
public static Supplies InsertSuppliesToDatabaseAndReturn(this MagicCarpetDbContext dbContext, string? id = null, TourType type = TourType.Beach, int count = 20, DateTime? date = null, List<(string, int)>? tours = null)
|
||||
|
||||
@@ -133,7 +133,7 @@ internal class AgencyStorageContractTests : BaseStorageContractTest
|
||||
|
||||
private Agency InsertAgencyToDatabaseAndReturn(string id, TourType type, int count, List<(string, int)>? tours = null)
|
||||
{
|
||||
var agency = new Agency { Id = id, Type = type, Count = count, Tours = [] };
|
||||
var agency = new Agency { Id = id, TourType = type, Count = count, Tours = [] };
|
||||
if (tours is not null)
|
||||
{
|
||||
foreach (var elem in tours)
|
||||
@@ -152,7 +152,7 @@ internal class AgencyStorageContractTests : BaseStorageContractTest
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(actual.Id, Is.EqualTo(expected.Id));
|
||||
Assert.That(actual.Type, Is.EqualTo(expected.Type));
|
||||
Assert.That(actual.TourType, Is.EqualTo(expected.TourType));
|
||||
Assert.That(actual.Count, Is.EqualTo(expected.Count));
|
||||
});
|
||||
if (expected.Tours is not null)
|
||||
@@ -180,7 +180,7 @@ internal class AgencyStorageContractTests : BaseStorageContractTest
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(actual.Id, Is.EqualTo(expected.Id));
|
||||
Assert.That(actual.Type, Is.EqualTo(expected.Type));
|
||||
Assert.That(actual.TourType, Is.EqualTo(expected.TourType));
|
||||
Assert.That(actual.Count, Is.EqualTo(expected.Count));
|
||||
});
|
||||
if (expected.Tours is not null)
|
||||
|
||||
@@ -125,7 +125,7 @@ internal class SuppliesStorageContractTests : BaseStorageContractTest
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(actual.Id, Is.EqualTo(expected.Id));
|
||||
Assert.That(actual.Type, Is.EqualTo(expected.Type));
|
||||
Assert.That(actual.TourType, Is.EqualTo(expected.Type));
|
||||
Assert.That(actual.ProductuionDate, Is.EqualTo(expected.ProductuionDate));
|
||||
Assert.That(actual.Count, Is.EqualTo(expected.Count));
|
||||
});
|
||||
@@ -154,7 +154,7 @@ internal class SuppliesStorageContractTests : BaseStorageContractTest
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(actual.Id, Is.EqualTo(expected.Id));
|
||||
Assert.That(actual.Type, Is.EqualTo(expected.Type));
|
||||
Assert.That(actual.Type, Is.EqualTo(expected.TourType));
|
||||
Assert.That(actual.ProductuionDate, Is.EqualTo(expected.ProductuionDate));
|
||||
Assert.That(actual.Count, Is.EqualTo(expected.Count));
|
||||
});
|
||||
|
||||
@@ -0,0 +1,297 @@
|
||||
using AutoMapper;
|
||||
using MagicCarpetContracts.BindingModels;
|
||||
using MagicCarpetContracts.BusinessLogicContracts;
|
||||
using MagicCarpetContracts.DataModels;
|
||||
using MagicCarpetContracts.Enums;
|
||||
using MagicCarpetContracts.Exceptions;
|
||||
using MagicCarpetContracts.ViewModels;
|
||||
using MagicCarpetWebApi.Adapters;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Moq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetTests.WebApiAdapterTests;
|
||||
|
||||
[TestFixture]
|
||||
internal class SuppliesAdapterTests
|
||||
{
|
||||
private Mock<ISuppliesBusinessLogicContract> _suppliesBusinessLogicContract;
|
||||
private SuppliesAdapter _adapter;
|
||||
private Mock<ILogger<SuppliesAdapter>> _logger;
|
||||
private IMapper? _mapper;
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void OneTimeSetUp()
|
||||
{
|
||||
_suppliesBusinessLogicContract = new Mock<ISuppliesBusinessLogicContract>();
|
||||
_logger = new Mock<ILogger<SuppliesAdapter>>();
|
||||
_adapter = new SuppliesAdapter(_suppliesBusinessLogicContract.Object, _logger.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAllComponents_WhenSuppliesExist_ReturnOk()
|
||||
{
|
||||
// Arrange
|
||||
var supplies = new List<SuppliesDataModel>
|
||||
{
|
||||
new SuppliesDataModel(Guid.NewGuid().ToString(), TourType.Ski, DateTime.Now, 5, []),
|
||||
new SuppliesDataModel(Guid.NewGuid().ToString(), TourType.Ski, DateTime.Now.AddDays(1), 10, [])
|
||||
};
|
||||
_suppliesBusinessLogicContract.Setup(x => x.GetAllComponents()).Returns(supplies);
|
||||
// Act
|
||||
var result = _adapter.GetAllComponents();
|
||||
var list = (List<SuppliesViewModel>)result.Result!;
|
||||
// Assert
|
||||
Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||
Assert.That(list.Count, Is.EqualTo(2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAllComponents_WhenListNull_ReturnNotFound()
|
||||
{
|
||||
// Arrange
|
||||
_suppliesBusinessLogicContract.Setup(x => x.GetAllComponents()).Throws(new NullListException());
|
||||
// Act
|
||||
var result = _adapter.GetAllComponents();
|
||||
// Assert
|
||||
Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.NotFound));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAllComponents_WhenStorageException_ReturnsInternalServerError()
|
||||
{
|
||||
// Arrange
|
||||
_suppliesBusinessLogicContract.Setup(x => x.GetAllComponents()).Throws(new StorageException(new InvalidOperationException()));
|
||||
// Act
|
||||
var result = _adapter.GetAllComponents();
|
||||
// Assert
|
||||
Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.InternalServerError));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetComponentByData_WhenSupplies_ReturnOK()
|
||||
{
|
||||
var supply = new SuppliesDataModel(Guid.NewGuid().ToString(), TourType.Ski, DateTime.Now, 5, []);
|
||||
// Arrange
|
||||
_suppliesBusinessLogicContract.Setup(x => x.GetComponentByData(supply.Id)).Returns(supply);
|
||||
// Act
|
||||
var result = _adapter.GetComponentByData(supply.Id);
|
||||
Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||
var resultData = (SuppliesViewModel)result.Result!;
|
||||
Assert.That(resultData.Id!, Is.EqualTo(supply.Id));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetComponentByData_WhenComponentNotFound_ReturnsNotFound()
|
||||
{
|
||||
// Arrange
|
||||
var data = "test";
|
||||
_suppliesBusinessLogicContract.Setup(x => x.GetComponentByData(data)).Throws(new ElementNotFoundException(""));
|
||||
// Act
|
||||
var result = _adapter.GetComponentByData(data);
|
||||
// Assert
|
||||
Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.NotFound));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetComponentByData_WhenStorageException_ReturnInternalServerError()
|
||||
{
|
||||
// Arrange
|
||||
var data = "test";
|
||||
_suppliesBusinessLogicContract.Setup(x => x.GetComponentByData(data)).Throws(new StorageException(new InvalidOperationException()));
|
||||
// Act
|
||||
var result = _adapter.GetComponentByData(data);
|
||||
// Assert
|
||||
Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.InternalServerError));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InsertComponent_WhenValidData_ReturnsNoContent()
|
||||
{
|
||||
// Arrange
|
||||
var supply = new SuppliesBindingModel
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
TourType = TourType.Ski,
|
||||
ProductuionDate = DateTime.Now,
|
||||
Count = 5,
|
||||
Tours = [new TourSuppliesBindingModel { TourId = Guid.NewGuid().ToString(), SuppliesId = Guid.NewGuid().ToString(), Count = 5 }]
|
||||
};
|
||||
_suppliesBusinessLogicContract.Setup(x => x.InsertComponent(It.IsAny<SuppliesDataModel>()));
|
||||
// Act
|
||||
var result = _adapter.InsertComponent(supply);
|
||||
// Assert
|
||||
Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.NoContent));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InsertComponent_WhenDataIsNull_ReturnsBadRequest()
|
||||
{
|
||||
// Arrange
|
||||
_suppliesBusinessLogicContract.Setup(x => x.InsertComponent(null)).Throws(new ArgumentNullException());
|
||||
// Act
|
||||
var result = _adapter.InsertComponent(null);
|
||||
// Assert
|
||||
Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InsertComponent_WhenValidationError_ReturnBadRequest()
|
||||
{
|
||||
// Arrange
|
||||
var supply = new SuppliesBindingModel
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
TourType = TourType.None,
|
||||
ProductuionDate = DateTime.Now,
|
||||
Count = 5,
|
||||
Tours = []
|
||||
};
|
||||
// Act
|
||||
var result = _adapter.InsertComponent(supply);
|
||||
// Assert
|
||||
Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InsertComponent_WhenElementExistException_ReturnBadRequest()
|
||||
{
|
||||
// Arrange
|
||||
var supply1 = new SuppliesBindingModel
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
TourType = TourType.None,
|
||||
ProductuionDate = DateTime.Now,
|
||||
Count = 5,
|
||||
Tours = []
|
||||
};
|
||||
_suppliesBusinessLogicContract.Setup(x => x.InsertComponent(It.IsAny<SuppliesDataModel>())).Throws(new ElementExistsException("Data", "Data"));
|
||||
// Act
|
||||
var result = _adapter.InsertComponent(supply1);
|
||||
// Assert
|
||||
Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InsertComponent_WhenStorageException_ReturnBadRequest()
|
||||
{
|
||||
// Arrange
|
||||
var supply = new SuppliesBindingModel
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
TourType = TourType.Ski,
|
||||
ProductuionDate = DateTime.Now,
|
||||
Count = 5,
|
||||
Tours = new List<TourSuppliesBindingModel>()
|
||||
};
|
||||
_suppliesBusinessLogicContract.Setup(x => x.InsertComponent(It.IsAny<SuppliesDataModel>())).Throws(new StorageException(new InvalidOperationException()));
|
||||
// Act
|
||||
var result = _adapter.InsertComponent(supply);
|
||||
// Assert
|
||||
Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UpdateComponent_WhenValidData_ReturnsNoContent()
|
||||
{
|
||||
// Arrange
|
||||
var supply = new SuppliesBindingModel { Id = Guid.NewGuid().ToString() };
|
||||
_suppliesBusinessLogicContract.Setup(x => x.UpdateComponent(It.IsAny<SuppliesDataModel>()));
|
||||
// Act
|
||||
var result = _adapter.UpdateComponent(supply);
|
||||
// Assert
|
||||
Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.NoContent));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UpdateComponent_WhenDataIsNull_ReturnsBadRequest()
|
||||
{
|
||||
// Arrange
|
||||
var component = new SuppliesBindingModel { Id = Guid.NewGuid().ToString() };
|
||||
_suppliesBusinessLogicContract.Setup(x => x.UpdateComponent(It.IsAny<SuppliesDataModel>())).Throws(new ElementNotFoundException(""));
|
||||
// Act
|
||||
var result = _adapter.UpdateComponent(component);
|
||||
// Assert
|
||||
Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UpdateComponent_WhenValidationError_ReturnBadRequest()
|
||||
{
|
||||
// Arrange
|
||||
var supply = new SuppliesBindingModel
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
TourType = TourType.Ski,
|
||||
ProductuionDate = DateTime.Now,
|
||||
Count = 5,
|
||||
Tours = []
|
||||
};
|
||||
_suppliesBusinessLogicContract.Setup(x => x.UpdateComponent(It.IsAny<SuppliesDataModel>())).Throws(new ValidationException(""));
|
||||
// Act
|
||||
var result = _adapter.UpdateComponent(supply);
|
||||
// Assert
|
||||
Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UpdateComponent_WhenElementNotFoundException_ReturnBadRequest()
|
||||
{
|
||||
// Arrange
|
||||
var supply = new SuppliesBindingModel
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
TourType = TourType.None,
|
||||
ProductuionDate = DateTime.Now,
|
||||
Count = 5,
|
||||
Tours = []
|
||||
};
|
||||
_suppliesBusinessLogicContract.Setup(x => x.UpdateComponent(It.IsAny<SuppliesDataModel>())).Throws(new ElementNotFoundException(""));
|
||||
// Act
|
||||
var result = _adapter.UpdateComponent(supply);
|
||||
// Assert
|
||||
Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UpdateComponent_WhenElementExistException_ReturnBadRequest()
|
||||
{
|
||||
// Arrange
|
||||
var supply1 = new SuppliesBindingModel
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
TourType = TourType.None,
|
||||
ProductuionDate = DateTime.Now,
|
||||
Count = 5,
|
||||
Tours = []
|
||||
};
|
||||
_suppliesBusinessLogicContract.Setup(x => x.UpdateComponent(It.IsAny<SuppliesDataModel>())).Throws(new ElementExistsException("Data", "Data"));
|
||||
// Act
|
||||
var result = _adapter.UpdateComponent(supply1);
|
||||
Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UpdateComponent_WhenStorageException_ReturnBadRequest()
|
||||
{
|
||||
// Arrange
|
||||
var supply = new SuppliesBindingModel
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
TourType = TourType.Ski,
|
||||
ProductuionDate = DateTime.Now,
|
||||
Count = 5,
|
||||
Tours = new List<TourSuppliesBindingModel>()
|
||||
};
|
||||
_suppliesBusinessLogicContract.Setup(x => x.UpdateComponent(It.IsAny<SuppliesDataModel>())).Throws(new StorageException(new InvalidOperationException()));
|
||||
// Act
|
||||
var result = _adapter.UpdateComponent(supply);
|
||||
// Assert
|
||||
Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using MagicCarpetContracts.BindingModels;
|
||||
using MagicCarpetContracts.DataModels;
|
||||
using MagicCarpetContracts.Enums;
|
||||
using MagicCarpetContracts.ViewModels;
|
||||
using MagicCarpetDatabase.Models;
|
||||
using MagicCarpetTests.Infrastructure;
|
||||
using System;
|
||||
@@ -15,12 +16,12 @@ namespace MagicCarpetTests.WebApiControllersTests;
|
||||
[TestFixture]
|
||||
internal class AgencyControllerTests : BaseWebApiControllerTest
|
||||
{
|
||||
private string _componentId;
|
||||
private string _tourId;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_componentId = MagicCarpetDbContext.InsertTourToDatabaseAndReturn().Id;
|
||||
_tourId = MagicCarpetDbContext.InsertTourToDatabaseAndReturn().Id;
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
@@ -31,7 +32,7 @@ internal class AgencyControllerTests : BaseWebApiControllerTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetAllAgencys_WhenHaveRecords_ShouldSuccess_Test()
|
||||
public async Task GetAllAgencies_WhenHaveRecords_ShouldSuccess_Test()
|
||||
{
|
||||
// Arrange
|
||||
var agency = MagicCarpetDbContext.InsertAgencyToDatabaseAndReturn();
|
||||
@@ -92,8 +93,8 @@ internal class AgencyControllerTests : BaseWebApiControllerTest
|
||||
public async Task Post_ShouldSuccess_Test()
|
||||
{
|
||||
//Arrange
|
||||
MagicCarpetDbContext.InsertAgencyToDatabaseAndReturn(tours: [(_componentId, 5)]);
|
||||
var agency = CreateModel(components: [(_componentId, 5)]);
|
||||
MagicCarpetDbContext.InsertAgencyToDatabaseAndReturn(tours: [(_tourId, 5)]);
|
||||
var agency = CreateModel(tours: [(_tourId, 5)]);
|
||||
//Act
|
||||
var response = await HttpClient.PostAsync($"/api/agency", MakeContent(agency));
|
||||
//Assert
|
||||
@@ -141,7 +142,7 @@ internal class AgencyControllerTests : BaseWebApiControllerTest
|
||||
{
|
||||
//Arrange
|
||||
MagicCarpetDbContext.InsertAgencyToDatabaseAndReturn();
|
||||
var agency = CreateModel(components: [(_componentId, 5)]);
|
||||
var agency = CreateModel(tours: [(_tourId, 5)]);
|
||||
MagicCarpetDbContext.InsertAgencyToDatabaseAndReturn(agency.Id);
|
||||
//Act
|
||||
var response = await HttpClient.PutAsync($"/api/agency", MakeContent(agency));
|
||||
@@ -218,12 +219,12 @@ internal class AgencyControllerTests : BaseWebApiControllerTest
|
||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||
}
|
||||
|
||||
private static AgencyBindingModel CreateModel(string? id = null, TourType tourType = TourType.Beach, int count = 21, List<(string, int)>? components = null)
|
||||
private static AgencyBindingModel CreateModel(string? id = null, TourType tourType = TourType.Ski, int count = 21, List<(string, int)>? tours = null)
|
||||
{
|
||||
var agency = new AgencyBindingModel() { Id = id ?? Guid.NewGuid().ToString(), TourType = tourType, Count = count, Tours = [] };
|
||||
if (components is not null)
|
||||
if (tours is not null)
|
||||
{
|
||||
foreach (var elem in components)
|
||||
foreach (var elem in tours)
|
||||
{
|
||||
agency.Tours.Add(new TourAgencyBindingModel { AgencyId = agency.Id, TourId = elem.Item1, Count = elem.Item2 });
|
||||
}
|
||||
@@ -241,20 +242,20 @@ internal class AgencyControllerTests : BaseWebApiControllerTest
|
||||
});
|
||||
if (expected.Tours is not null)
|
||||
{
|
||||
Assert.That(actual.Components, Is.Not.Null);
|
||||
Assert.That(actual.Components, Has.Count.EqualTo(expected.Tours.Count));
|
||||
for (int i = 0; i < actual.Components.Count; ++i)
|
||||
Assert.That(actual.Tours, Is.Not.Null);
|
||||
Assert.That(actual.Tours, Has.Count.EqualTo(expected.Tours.Count));
|
||||
for (int i = 0; i < actual.Tours.Count; ++i)
|
||||
{
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(actual.Components[i].TourId, Is.EqualTo(expected.Tours[i].TourId));
|
||||
Assert.That(actual.Components[i].Count, Is.EqualTo(expected.Tours[i].Count));
|
||||
Assert.That(actual.Tours[i].TourId, Is.EqualTo(expected.Tours[i].TourId));
|
||||
Assert.That(actual.Tours[i].Count, Is.EqualTo(expected.Tours[i].Count));
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.That(actual.Components, Is.Null);
|
||||
Assert.That(actual.Tours, Is.Null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ internal class SaleControllerTests : BaseWebApiControllerTest
|
||||
MagicCarpetDbContext.RemoveEmployeesFromDatabase();
|
||||
MagicCarpetDbContext.RemoveClientsFromDatabase();
|
||||
MagicCarpetDbContext.RemoveToursFromDatabase();
|
||||
MagicCarpetDbContext.RemoveAgenciesFromDatabase();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -310,6 +311,7 @@ internal class SaleControllerTests : BaseWebApiControllerTest
|
||||
public async Task Post_ShouldSuccess_Test()
|
||||
{
|
||||
//Arrange
|
||||
MagicCarpetDbContext.InsertAgencyToDatabaseAndReturn();
|
||||
MagicCarpetDbContext.InsertSaleToDatabaseAndReturn(_employeeId, null, tours: [(_tourId, 5, 1.1)]);
|
||||
var saleModel = CreateModel(_employeeId, _clientId, _tourId);
|
||||
//Act
|
||||
|
||||
@@ -0,0 +1,254 @@
|
||||
using MagicCarpetContracts.BindingModels;
|
||||
using MagicCarpetContracts.DataModels;
|
||||
using MagicCarpetContracts.Enums;
|
||||
using MagicCarpetContracts.ViewModels;
|
||||
using MagicCarpetDatabase.Models;
|
||||
using MagicCarpetTests.Infrastructure;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetTests.WebApiControllersTests;
|
||||
|
||||
[TestFixture]
|
||||
internal class SuppliesControllerTests : BaseWebApiControllerTest
|
||||
{
|
||||
private string _componentId;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_componentId = MagicCarpetDbContext.InsertTourToDatabaseAndReturn().Id;
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
MagicCarpetDbContext.RemoveToursFromDatabase();
|
||||
MagicCarpetDbContext.RemoveSuppliesFromDatabase();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetAllWarehouses_WhenHaveRecords_ShouldSuccess_Test()
|
||||
{
|
||||
// Arrange
|
||||
var supply = MagicCarpetDbContext.InsertSuppliesToDatabaseAndReturn();
|
||||
MagicCarpetDbContext.InsertSuppliesToDatabaseAndReturn();
|
||||
MagicCarpetDbContext.InsertSuppliesToDatabaseAndReturn();
|
||||
// Act
|
||||
var response = await HttpClient.GetAsync("/api/supplies");
|
||||
// Assert
|
||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||
var data = await GetModelFromResponseAsync<List<SuppliesViewModel>>(response);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(data, Is.Not.Null);
|
||||
Assert.That(data, Has.Count.EqualTo(3));
|
||||
});
|
||||
AssertElement(data.First(x => x.Id == supply.Id), supply);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetList_WhenNoRecords_ShouldSuccess_Test()
|
||||
{
|
||||
//Act
|
||||
var response = await HttpClient.GetAsync("/api/supplies");
|
||||
//Assert
|
||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||
var data = await GetModelFromResponseAsync<List<AgencyViewModel>>(response);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(data, Is.Not.Null);
|
||||
Assert.That(data, Has.Count.EqualTo(0));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetElement_ById_WhenHaveRecord_ShouldSuccess_Test()
|
||||
{
|
||||
//Arrange
|
||||
var supplies = MagicCarpetDbContext.InsertSuppliesToDatabaseAndReturn();
|
||||
//Act
|
||||
var response = await HttpClient.GetAsync($"/api/supplies/{supplies.Id}");
|
||||
//Assert
|
||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||
AssertElement(await GetModelFromResponseAsync<SuppliesViewModel>(response), supplies);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetElement_ById_WhenNoRecord_ShouldNotFound_Test()
|
||||
{
|
||||
//Arrange
|
||||
MagicCarpetDbContext.InsertSuppliesToDatabaseAndReturn();
|
||||
//Act
|
||||
var response = await HttpClient.GetAsync($"/api/supplies/{Guid.NewGuid()}");
|
||||
//Assert
|
||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NotFound));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Post_ShouldSuccess_Test()
|
||||
{
|
||||
//Arrange
|
||||
MagicCarpetDbContext.InsertSuppliesToDatabaseAndReturn(tours: [(_componentId, 5)]);
|
||||
var supplies = CreateModel(components: [(_componentId, 5)]);
|
||||
//Act
|
||||
var response = await HttpClient.PostAsync($"/api/supplies", MakeContent(supplies));
|
||||
//Assert
|
||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NoContent));
|
||||
AssertElement(MagicCarpetDbContext.GetSuppliesFromDatabaseById(supplies.Id!), supplies);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Post_WhenSendEmptyData_ShouldBadRequest_Test()
|
||||
{
|
||||
//Act
|
||||
var response = await HttpClient.PostAsync($"/api/supplies", MakeContent(string.Empty));
|
||||
//Assert
|
||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Post_WhenSendWrongFormatData_ShouldBadRequest_Test()
|
||||
{
|
||||
//Act
|
||||
var response = await HttpClient.PostAsync($"/api/supplies", MakeContent(new { Data = "test", Position = 10 }));
|
||||
//Assert
|
||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Post_WhenDataIsIncorrect_ShouldBadRequest_Test()
|
||||
{
|
||||
//Arrange
|
||||
var suppliesIdIncorrect = new SuppliesViewModel { Id = "Id", TourType = TourType.None, Tours = [] };
|
||||
var suppliesWithTypeIncorrect = new SuppliesViewModel { Id = Guid.NewGuid().ToString(), TourType = TourType.None, Tours = [] };
|
||||
//Act
|
||||
var responseWithIdIncorrect = await HttpClient.PostAsync($"/api/supplies", MakeContent(suppliesIdIncorrect));
|
||||
var responseWithTypeIncorrect = await HttpClient.PostAsync($"/api/supplies", MakeContent(suppliesWithTypeIncorrect));
|
||||
//Assert
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(responseWithIdIncorrect.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest), "Id is incorrect");
|
||||
Assert.That(responseWithTypeIncorrect.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest), "Type is incorrect");
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Put_ShouldSuccess_Test()
|
||||
{
|
||||
//Arrange
|
||||
MagicCarpetDbContext.InsertSuppliesToDatabaseAndReturn();
|
||||
var supplies = CreateModel(components: [(_componentId, 5)]);
|
||||
MagicCarpetDbContext.InsertSuppliesToDatabaseAndReturn(supplies.Id);
|
||||
//Act
|
||||
var response = await HttpClient.PutAsync($"/api/supplies", MakeContent(supplies));
|
||||
//Assert
|
||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NoContent));
|
||||
MagicCarpetDbContext.ChangeTracker.Clear();
|
||||
AssertElement(MagicCarpetDbContext.GetSuppliesFromDatabaseById(supplies.Id!), supplies);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Put_WhenNoFoundRecord_ShouldBadRequest_Test()
|
||||
{
|
||||
//Arrange
|
||||
var furniture = CreateModel();
|
||||
MagicCarpetDbContext.InsertSuppliesToDatabaseAndReturn();
|
||||
//Act
|
||||
var response = await HttpClient.PutAsync($"/api/supplies", MakeContent(furniture));
|
||||
//Assert
|
||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Put_WhenSendEmptyData_ShouldBadRequest_Test()
|
||||
{
|
||||
//Act
|
||||
var response = await HttpClient.PutAsync($"/api/supplies", MakeContent(string.Empty));
|
||||
//Assert
|
||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Put_WhenSendWrongFormatData_ShouldBadRequest_Test()
|
||||
{
|
||||
//Act
|
||||
var response = await HttpClient.PutAsync($"/api/supplies", MakeContent(new { Data = "test", Position = 10 }));
|
||||
//Assert
|
||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||
}
|
||||
|
||||
|
||||
private static SuppliesBindingModel CreateModel(string? id = null, TourType type = TourType.Ski, int count = 21, DateTime? date = null, List<(string, int)>? components = null)
|
||||
{
|
||||
var Supply = new SuppliesBindingModel() { Id = id ?? Guid.NewGuid().ToString(), TourType = type, Count = count, ProductuionDate = date ?? DateTime.UtcNow,Tours = [] };
|
||||
if (components is not null)
|
||||
{
|
||||
foreach (var elem in components)
|
||||
{
|
||||
Supply.Tours.Add(new TourSuppliesBindingModel { SuppliesId = Supply.Id, TourId = elem.Item1, Count = elem.Item2 });
|
||||
}
|
||||
}
|
||||
return Supply;
|
||||
}
|
||||
|
||||
private static void AssertElement(SuppliesViewModel? actual, Supplies expected)
|
||||
{
|
||||
Assert.That(actual, Is.Not.Null);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(actual.Id, Is.EqualTo(expected.Id));
|
||||
Assert.That(actual.Count, Is.EqualTo(expected.Count));
|
||||
Assert.That(actual.ProductuionDate.Date, Is.EqualTo(expected.ProductuionDate.Date));
|
||||
});
|
||||
if (expected.Tours is not null)
|
||||
{
|
||||
Assert.That(actual.Tours, Is.Not.Null);
|
||||
Assert.That(actual.Tours, Has.Count.EqualTo(expected.Tours.Count));
|
||||
for (int i = 0; i < actual.Tours.Count; ++i)
|
||||
{
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(actual.Tours[i].TourId, Is.EqualTo(expected.Tours[i].TourId));
|
||||
Assert.That(actual.Tours[i].Count, Is.EqualTo(expected.Tours[i].Count));
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.That(actual.Tours, Is.Null);
|
||||
}
|
||||
}
|
||||
|
||||
private static void AssertElement(Supplies? actual, SuppliesBindingModel expected)
|
||||
{
|
||||
Assert.That(actual, Is.Not.Null);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(actual.Id, Is.EqualTo(expected.Id));
|
||||
Assert.That(actual.Count, Is.EqualTo(expected.Count));
|
||||
Assert.That(actual.ProductuionDate.Date, Is.EqualTo(expected.ProductuionDate.Date));
|
||||
});
|
||||
if (expected.Tours is not null)
|
||||
{
|
||||
Assert.That(actual.Tours, Is.Not.Null);
|
||||
Assert.That(actual.Tours, Has.Count.EqualTo(expected.Tours.Count));
|
||||
for (int i = 0; i < actual.Tours.Count; ++i)
|
||||
{
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(actual.Tours[i].TourId, Is.EqualTo(expected.Tours[i].TourId));
|
||||
Assert.That(actual.Tours[i].Count, Is.EqualTo(expected.Tours[i].Count));
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.That(actual.Tours, Is.Null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,15 @@
|
||||
using MagicCarpetContracts.AdapterContracts;
|
||||
using MagicCarpetContracts.BindingModels;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace MagicCarpetWebApi.Controllers;
|
||||
|
||||
[Authorize]
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[Produces("application/json")]
|
||||
public class AgencyController(IAgencyAdapter adapter) : ControllerBase
|
||||
{
|
||||
private readonly IAgencyAdapter _adapter = adapter;
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
using MagicCarpetContracts.AdapterContracts;
|
||||
using MagicCarpetContracts.BindingModels;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace MagicCarpetWebApi.Controllers;
|
||||
|
||||
[Authorize]
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[Produces("application/json")]
|
||||
public class SuppliesController(ISuppliesAdapter adapter) : ControllerBase
|
||||
{
|
||||
private readonly ISuppliesAdapter _adapter = adapter;
|
||||
|
||||
Reference in New Issue
Block a user