From a64e1a9433a0d1ae340a38752f8b87cd7df8ad78 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 13 Mar 2021 16:14:42 +0200 Subject: Replaced all "new Guid()" with "Guid.NewGuid()" in service tests --- src/Services/DevHive.Services.Tests/PostService.Tests.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/Services/DevHive.Services.Tests/PostService.Tests.cs') diff --git a/src/Services/DevHive.Services.Tests/PostService.Tests.cs b/src/Services/DevHive.Services.Tests/PostService.Tests.cs index 137b8d1..b7f9a9d 100644 --- a/src/Services/DevHive.Services.Tests/PostService.Tests.cs +++ b/src/Services/DevHive.Services.Tests/PostService.Tests.cs @@ -107,7 +107,7 @@ namespace DevHive.Services.Tests [Test] public async Task GetPostById_ReturnsThePost_WhenItExists() { - Guid creatorId = new Guid(); + Guid creatorId = Guid.NewGuid(); User creator = new User { Id = creatorId }; Post post = new Post { @@ -127,7 +127,7 @@ namespace DevHive.Services.Tests this.UserRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny())).Returns(Task.FromResult(user)); this.MapperMock.Setup(p => p.Map(It.IsAny())).Returns(readPostServiceModel); - ReadPostServiceModel result = await this.PostService.GetPostById(new Guid()); + ReadPostServiceModel result = await this.PostService.GetPostById(Guid.NewGuid()); Assert.AreEqual(MESSAGE, result.Message); } @@ -136,7 +136,7 @@ namespace DevHive.Services.Tests public void GetPostById_ThorwsException_WhenTheUserDoesNotExist() { const string EXCEPTION_MESSAGE = "The user does not exist!"; - Guid creatorId = new Guid(); + Guid creatorId = Guid.NewGuid(); User creator = new User { Id = creatorId }; Post post = new Post { @@ -146,7 +146,7 @@ namespace DevHive.Services.Tests this.PostRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny())).Returns(Task.FromResult(post)); - Exception ex = Assert.ThrowsAsync(() => this.PostService.GetPostById(new Guid()), "GetPostById does not throw exception when the user does not exist"); + Exception ex = Assert.ThrowsAsync(() => this.PostService.GetPostById(Guid.NewGuid()), "GetPostById does not throw exception when the user does not exist"); Assert.AreEqual(EXCEPTION_MESSAGE, ex.Message); } @@ -155,7 +155,7 @@ namespace DevHive.Services.Tests public void GetPostById_ThrowsException_WhenCommentDoesNotExist() { string exceptionMessage = "The post does not exist!"; - Guid creatorId = new Guid(); + Guid creatorId = Guid.NewGuid(); User user = new User { Id = creatorId, @@ -164,7 +164,7 @@ namespace DevHive.Services.Tests this.PostRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny())).Returns(Task.FromResult(null)); this.UserRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny())).Returns(Task.FromResult(user)); - Exception ex = Assert.ThrowsAsync(() => this.PostService.GetPostById(new Guid())); + Exception ex = Assert.ThrowsAsync(() => this.PostService.GetPostById(Guid.NewGuid())); Assert.AreEqual(exceptionMessage, ex.Message, "Incorecct exception message"); } @@ -242,7 +242,7 @@ namespace DevHive.Services.Tests [TestCase(false)] public async Task Deletepost_ShouldReturnIfDeletionIsSuccessfull_WhenPostExists(bool shouldPass) { - Guid id = new Guid(); + Guid id = Guid.NewGuid(); Post post = new Post(); this.PostRepositoryMock.Setup(p => p.DoesPostExist(It.IsAny())).Returns(Task.FromResult(true)); @@ -258,7 +258,7 @@ namespace DevHive.Services.Tests public void DeletePost_ThrowsException_WhenPostDoesNotExist() { string exceptionMessage = "Post does not exist!"; - Guid id = new Guid(); + Guid id = Guid.NewGuid(); this.PostRepositoryMock.Setup(p => p.DoesPostExist(It.IsAny())).Returns(Task.FromResult(false)); -- cgit v1.2.3