diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-03-13 16:14:42 +0200 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-03-13 16:14:42 +0200 |
| commit | a64e1a9433a0d1ae340a38752f8b87cd7df8ad78 (patch) | |
| tree | 1f3acb3ff754d2f4a775fe935f80e584f9062c9e /src/Services/DevHive.Services.Tests/PostService.Tests.cs | |
| parent | e725d029bcd05f9c945312a3c931064a14d2bd5e (diff) | |
| download | DevHive-a64e1a9433a0d1ae340a38752f8b87cd7df8ad78.tar DevHive-a64e1a9433a0d1ae340a38752f8b87cd7df8ad78.tar.gz DevHive-a64e1a9433a0d1ae340a38752f8b87cd7df8ad78.zip | |
Replaced all "new Guid()" with "Guid.NewGuid()" in service tests
Diffstat (limited to 'src/Services/DevHive.Services.Tests/PostService.Tests.cs')
| -rw-r--r-- | src/Services/DevHive.Services.Tests/PostService.Tests.cs | 16 |
1 files changed, 8 insertions, 8 deletions
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<Guid>())).Returns(Task.FromResult(user)); this.MapperMock.Setup(p => p.Map<ReadPostServiceModel>(It.IsAny<Post>())).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<Guid>())).Returns(Task.FromResult(post)); - Exception ex = Assert.ThrowsAsync<ArgumentException>(() => this.PostService.GetPostById(new Guid()), "GetPostById does not throw exception when the user does not exist"); + Exception ex = Assert.ThrowsAsync<ArgumentException>(() => 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<Guid>())).Returns(Task.FromResult<Post>(null)); this.UserRepositoryMock.Setup(p => p.GetByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult(user)); - Exception ex = Assert.ThrowsAsync<ArgumentException>(() => this.PostService.GetPostById(new Guid())); + Exception ex = Assert.ThrowsAsync<ArgumentException>(() => 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<Guid>())).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<Guid>())).Returns(Task.FromResult(false)); |
