From 3ed50b3e592822482eeb3e36da483c6cdef27cd1 Mon Sep 17 00:00:00 2001 From: Danail Dimitrov Date: Wed, 27 Jan 2021 22:05:06 +0200 Subject: Fixed name inconsistency (TechnologyService.Create renamed to CreateTechnology) --- .../Interfaces/ITechnologyService.cs | 2 +- src/DevHive.Services/Services/TechnologyService.cs | 2 +- .../TechnologyServices.Tests.cs | 25 +++++++++------------- .../TechnologyController.Tests.cs | 4 ++-- .../Controllers/TechnologyController.cs | 2 +- 5 files changed, 15 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/DevHive.Services/Interfaces/ITechnologyService.cs b/src/DevHive.Services/Interfaces/ITechnologyService.cs index 1d4fa8b..4f75dbe 100644 --- a/src/DevHive.Services/Interfaces/ITechnologyService.cs +++ b/src/DevHive.Services/Interfaces/ITechnologyService.cs @@ -7,7 +7,7 @@ namespace DevHive.Services.Interfaces { public interface ITechnologyService { - Task Create(CreateTechnologyServiceModel technologyServiceModel); + Task CreateTechnology(CreateTechnologyServiceModel technologyServiceModel); Task GetTechnologyById(Guid id); HashSet GetTechnologies(); diff --git a/src/DevHive.Services/Services/TechnologyService.cs b/src/DevHive.Services/Services/TechnologyService.cs index 8f37273..3e7678e 100644 --- a/src/DevHive.Services/Services/TechnologyService.cs +++ b/src/DevHive.Services/Services/TechnologyService.cs @@ -21,7 +21,7 @@ namespace DevHive.Services.Services } #region Create - public async Task Create(CreateTechnologyServiceModel technologyServiceModel) + public async Task CreateTechnology(CreateTechnologyServiceModel technologyServiceModel) { if (await this._technologyRepository.DoesTechnologyNameExistAsync(technologyServiceModel.Name)) throw new ArgumentException("Technology already exists!"); diff --git a/src/DevHive.Tests/DevHive.Services.Tests/TechnologyServices.Tests.cs b/src/DevHive.Tests/DevHive.Services.Tests/TechnologyServices.Tests.cs index 51f63ba..569c87d 100644 --- a/src/DevHive.Tests/DevHive.Services.Tests/TechnologyServices.Tests.cs +++ b/src/DevHive.Tests/DevHive.Services.Tests/TechnologyServices.Tests.cs @@ -25,9 +25,9 @@ namespace DevHive.Services.Tests this.TechnologyService = new TechnologyService(this.TechnologyRepositoryMock.Object, this.MapperMock.Object); } - #region Create + #region CreateTechnology [Test] - public async Task Create_ReturnsNonEmptyGuid_WhenEntityIsAddedSuccessfully() + public async Task CreateTechnology_ReturnsNonEmptyGuid_WhenEntityIsAddedSuccessfully() { string technologyName = "Gosho Trapov"; Guid id = Guid.NewGuid(); @@ -46,13 +46,13 @@ namespace DevHive.Services.Tests this.TechnologyRepositoryMock.Setup(p => p.GetByNameAsync(It.IsAny())).Returns(Task.FromResult(technology)); this.MapperMock.Setup(p => p.Map(It.IsAny())).Returns(technology); - Guid result = await this.TechnologyService.Create(createTechnologyServiceModel); + Guid result = await this.TechnologyService.CreateTechnology(createTechnologyServiceModel); Assert.AreEqual(id, result); } [Test] - public async Task Create_ReturnsEmptyGuid_WhenEntityIsNotAddedSuccessfully() + public async Task CreateTechnology_ReturnsEmptyGuid_WhenEntityIsNotAddedSuccessfully() { string technologyName = "Gosho Trapov"; @@ -69,13 +69,13 @@ namespace DevHive.Services.Tests this.TechnologyRepositoryMock.Setup(p => p.AddAsync(It.IsAny())).Returns(Task.FromResult(false)); this.MapperMock.Setup(p => p.Map(It.IsAny())).Returns(technology); - Guid result = await this.TechnologyService.Create(createTechnologyServiceModel); + Guid result = await this.TechnologyService.CreateTechnology(createTechnologyServiceModel); Assert.IsTrue(result == Guid.Empty); } [Test] - public void Create_ThrowsArgumentException_WhenEntityAlreadyExists() + public void CreateTechnology_ThrowsArgumentException_WhenEntityAlreadyExists() { string exceptionMessage = "Technology already exists!"; string technologyName = "Gosho Trapov"; @@ -91,13 +91,13 @@ namespace DevHive.Services.Tests this.TechnologyRepositoryMock.Setup(p => p.DoesTechnologyNameExistAsync(It.IsAny())).Returns(Task.FromResult(true)); - Exception ex = Assert.ThrowsAsync(() => this.TechnologyService.Create(createTechnologyServiceModel)); + Exception ex = Assert.ThrowsAsync(() => this.TechnologyService.CreateTechnology(createTechnologyServiceModel)); Assert.AreEqual(exceptionMessage, ex.Message, "Incorecct exception message"); } #endregion - #region Read + #region GetTechnologyById [Test] public async Task GetTechnologyById_ReturnsTheTechnology_WhenItExists() { @@ -133,7 +133,7 @@ namespace DevHive.Services.Tests } #endregion - #region Update + #region UpdateTechnology [Test] [TestCase(true)] [TestCase(false)] @@ -193,7 +193,7 @@ namespace DevHive.Services.Tests } #endregion - #region Delete + #region DeleteTechnology [Test] [TestCase(true)] @@ -225,10 +225,5 @@ namespace DevHive.Services.Tests Assert.AreEqual(exceptionMessage, ex.Message, "Incorecct exception message"); } #endregion - - //Task.Run(async () => - //{ - - //}).GetAwaiter().GetResult(); } } diff --git a/src/DevHive.Tests/DevHive.Web.Tests/TechnologyController.Tests.cs b/src/DevHive.Tests/DevHive.Web.Tests/TechnologyController.Tests.cs index 72118b3..b7d38da 100644 --- a/src/DevHive.Tests/DevHive.Web.Tests/TechnologyController.Tests.cs +++ b/src/DevHive.Tests/DevHive.Web.Tests/TechnologyController.Tests.cs @@ -44,7 +44,7 @@ namespace DevHive.Web.Tests Guid id = Guid.NewGuid(); this.MapperMock.Setup(p => p.Map(It.IsAny())).Returns(createTechnologyServiceModel); - this.TechnologyServiceMock.Setup(p => p.Create(It.IsAny())).Returns(Task.FromResult(id)); + this.TechnologyServiceMock.Setup(p => p.CreateTechnology(It.IsAny())).Returns(Task.FromResult(id)); IActionResult result = this.TechnologyController.Create(createTechnologyWebModel).Result; @@ -76,7 +76,7 @@ namespace DevHive.Web.Tests string errorMessage = $"Could not create technology {NAME}"; this.MapperMock.Setup(p => p.Map(It.IsAny())).Returns(createTechnologyServiceModel); - this.TechnologyServiceMock.Setup(p => p.Create(It.IsAny())).Returns(Task.FromResult(id)); + this.TechnologyServiceMock.Setup(p => p.CreateTechnology(It.IsAny())).Returns(Task.FromResult(id)); IActionResult result = this.TechnologyController.Create(createTechnologyWebModel).Result; diff --git a/src/DevHive.Web/Controllers/TechnologyController.cs b/src/DevHive.Web/Controllers/TechnologyController.cs index 6453d12..9bf492c 100644 --- a/src/DevHive.Web/Controllers/TechnologyController.cs +++ b/src/DevHive.Web/Controllers/TechnologyController.cs @@ -29,7 +29,7 @@ namespace DevHive.Web.Controllers { CreateTechnologyServiceModel technologyServiceModel = this._technologyMapper.Map(createTechnologyWebModel); - Guid id = await this._technologyService.Create(technologyServiceModel); + Guid id = await this._technologyService.CreateTechnology(technologyServiceModel); return id == Guid.Empty ? new BadRequestObjectResult($"Could not create technology {createTechnologyWebModel.Name}") : -- cgit v1.2.3