diff options
5 files changed, 15 insertions, 20 deletions
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<Guid> Create(CreateTechnologyServiceModel technologyServiceModel); + Task<Guid> CreateTechnology(CreateTechnologyServiceModel technologyServiceModel); Task<CreateTechnologyServiceModel> GetTechnologyById(Guid id); HashSet<ReadTechnologyServiceModel> 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<Guid> Create(CreateTechnologyServiceModel technologyServiceModel) + public async Task<Guid> 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<string>())).Returns(Task.FromResult(technology)); this.MapperMock.Setup(p => p.Map<Technology>(It.IsAny<CreateTechnologyServiceModel>())).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<Technology>())).Returns(Task.FromResult(false)); this.MapperMock.Setup(p => p.Map<Technology>(It.IsAny<CreateTechnologyServiceModel>())).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<string>())).Returns(Task.FromResult(true)); - Exception ex = Assert.ThrowsAsync<ArgumentException>(() => this.TechnologyService.Create(createTechnologyServiceModel)); + Exception ex = Assert.ThrowsAsync<ArgumentException>(() => 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<CreateTechnologyServiceModel>(It.IsAny<CreateTechnologyWebModel>())).Returns(createTechnologyServiceModel); - this.TechnologyServiceMock.Setup(p => p.Create(It.IsAny<CreateTechnologyServiceModel>())).Returns(Task.FromResult(id)); + this.TechnologyServiceMock.Setup(p => p.CreateTechnology(It.IsAny<CreateTechnologyServiceModel>())).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<CreateTechnologyServiceModel>(It.IsAny<CreateTechnologyWebModel>())).Returns(createTechnologyServiceModel); - this.TechnologyServiceMock.Setup(p => p.Create(It.IsAny<CreateTechnologyServiceModel>())).Returns(Task.FromResult(id)); + this.TechnologyServiceMock.Setup(p => p.CreateTechnology(It.IsAny<CreateTechnologyServiceModel>())).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<CreateTechnologyServiceModel>(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}") : |
