Files
2024-08-31 12:07:21 +03:00

120 lines
4.0 KiB
C#

// using AutoMapper;
// using Silk_Road_Api.Models;
// using Silk_Road_Api.Profiles;
// using Silk_Road_Api.Repositories;
// using Silk_Road_Api.Services;
// using Silk_Road_Api.ViewModels;
// namespace Silk_Road_Api_Test;
// public class DrugServiceTest
// {
// [Fact]
// public async void GetDrug_ValidId_ReturnsADrug()
// {
// // Arrange
// IDrugService drugService = new DrugService(new MemoryRepository(), new MemoryManufacturerRepository(), new Mapper(new MapperConfiguration(cfg => cfg.AddProfile<DrugProfile>())));
// // Act
// var drug = await drugService.GetDrug(1);
// // Assert
// Assert.NotNull(drug);
// Assert.Equal(1, drug.id);
// }
// [Fact]
// public async void GetDrug_InvalidId_ThrowsError()
// {
// // Arrange
// IDrugService drugService = new DrugService(new MemoryRepository(), new MemoryManufacturerRepository(), new Mapper(new MapperConfiguration(cfg => cfg.AddProfile<DrugProfile>())));
// // Act
// var act = async () => await drugService.GetDrug(100);
// // Assert
// await Assert.ThrowsAsync<Exception>(act);
// }
// [Fact]
// public async void GetDrugs_WithPageSize10andPage1_Returns10Drugs()
// {
// // Arrange
// IDrugService drugService = new DrugService(new MemoryRepository(), new MemoryManufacturerRepository(), new Mapper(new MapperConfiguration(cfg => cfg.AddProfile<DrugProfile>())));
// SearchInput searchInput = new SearchInput
// {
// PageSize = 10,
// Page = 1
// };
// // Act
// var drugs = await drugService.GetDrugs(searchInput);
// // Assert
// Assert.NotNull(drugs);
// Assert.Equal(16, drugs.Total);
// Assert.Equal(10, drugs.Items.Count);
// }
// [Fact]
// public async void AddDrugs_Succesful()
// {
// // Arrange
// IDrugService drugService = new DrugService(new MemoryRepository(), new MemoryManufacturerRepository(), new Mapper(new MapperConfiguration(cfg => cfg.AddProfile<DrugProfile>())));
// DrugViewModel drug = new DrugViewModel
// {
// name = "Test Drug",
// description = "Test Description",
// price = 100,
// stock = 10,
// manufacturer = "Pfizer"
// };
// // Act
// var result = await drugService.AddDrug(drug);
// // Assert
// Assert.True(result);
// }
// [Fact]
// public async void UpdateDrugs_Succesful()
// {
// // Arrange
// IDrugService drugService = new DrugService(new MemoryRepository(), new MemoryManufacturerRepository(), new Mapper(new MapperConfiguration(cfg => cfg.AddProfile<DrugProfile>())));
// DrugViewModel drug = new DrugViewModel
// {
// id = 1,
// name = "Test Drug",
// description = "Test Description",
// price = 100,
// stock = 10,
// manufacturer = "Pfizer"
// };
// // Act
// var result = await drugService.UpdateDrug(drug);
// // Assert
// Assert.True(result);
// }
// [Fact]
// public async void DeleteDrugs_Succesful()
// {
// // Arrange
// IDrugService drugService = new DrugService(new MemoryRepository(), new MemoryManufacturerRepository(), new Mapper(new MapperConfiguration(cfg => cfg.AddProfile<DrugProfile>())));
// // Act
// var result = await drugService.DeleteDrug(1);
// // Assert
// Assert.True(result);
// }
// [Fact]
// public async void DeleteDrugs_InvalidId_ReturnsFalse()
// {
// // Arrange
// IDrugService drugService = new DrugService(new MemoryRepository(), new MemoryManufacturerRepository(), new Mapper(new MapperConfiguration(cfg => cfg.AddProfile<DrugProfile>())));
// // Act
// var result = await drugService.DeleteDrug(100);
// // Assert
// Assert.False(result);
// }
// }