School Commit Init
This commit is contained in:
+254
@@ -0,0 +1,254 @@
|
||||
using District_3_App.Repository;
|
||||
|
||||
namespace District_3_App_Tests.RepositoryTests
|
||||
{
|
||||
public class FancierProfileRepoTests
|
||||
{
|
||||
[Fact]
|
||||
public void AddLink_WithValidParameters_ReturnsTrue()
|
||||
{
|
||||
// Arrange
|
||||
FancierProfileRepo repo = new FancierProfileRepo();
|
||||
Guid userId = Guid.NewGuid();
|
||||
string linkToAdd = "www.google.com";
|
||||
|
||||
// Act
|
||||
bool result = repo.AddLink(userId, linkToAdd);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DeleteLink_WithValidParameters_ReturnsTrue()
|
||||
{
|
||||
// Arrange
|
||||
FancierProfileRepo repo = new FancierProfileRepo();
|
||||
Guid userId = Guid.NewGuid();
|
||||
string linkToAdd = "www.google.com";
|
||||
repo.AddLink(userId, linkToAdd);
|
||||
|
||||
// Act
|
||||
bool result = repo.DeleteLink(userId, linkToAdd);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetFrameNumber_WithValidParameters_ReturnsTrue()
|
||||
{
|
||||
// Arrange
|
||||
FancierProfileRepo repo = new FancierProfileRepo();
|
||||
Guid userId = Guid.NewGuid();
|
||||
int newFrameNumber = 5;
|
||||
|
||||
// Act
|
||||
bool result = repo.SetFrameNumber(userId, newFrameNumber);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DeleteFrameNumber_WithValidParameters_ReturnsTrue()
|
||||
{
|
||||
// Arrange
|
||||
FancierProfileRepo repo = new FancierProfileRepo();
|
||||
Guid userId = Guid.NewGuid();
|
||||
int newFrameNumber = 5;
|
||||
repo.SetFrameNumber(userId, newFrameNumber);
|
||||
|
||||
// Act
|
||||
bool result = repo.DeleteFrameNumber(userId);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetHashtag_WithValidParameters_ReturnsTrue()
|
||||
{
|
||||
// Arrange
|
||||
FancierProfileRepo repo = new FancierProfileRepo();
|
||||
Guid userId = Guid.NewGuid();
|
||||
string newHashtag = "#test";
|
||||
|
||||
// Act
|
||||
bool result = repo.SetHashtag(userId, newHashtag);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DeleteHashtag_WithValidParameters_ReturnsTrue()
|
||||
{
|
||||
// Arrange
|
||||
FancierProfileRepo repo = new FancierProfileRepo();
|
||||
Guid userId = Guid.NewGuid();
|
||||
string newHashtag = "#test";
|
||||
repo.SetHashtag(userId, newHashtag);
|
||||
|
||||
// Act
|
||||
bool result = repo.DeleteHashtag(userId);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddDailyMotto_WithValidParameters_ReturnsTrue()
|
||||
{
|
||||
// Arrange
|
||||
FancierProfileRepo repo = new FancierProfileRepo();
|
||||
Guid userId = Guid.NewGuid();
|
||||
string newMotto = "test";
|
||||
DateTime dateToRemove = DateTime.Now;
|
||||
|
||||
// Act
|
||||
bool result = repo.AddDailyMotto(userId, newMotto, dateToRemove);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DeleteDailyMotto_WithValidParameters_ReturnsTrue()
|
||||
{
|
||||
// Arrange
|
||||
FancierProfileRepo repo = new FancierProfileRepo();
|
||||
Guid userId = Guid.NewGuid();
|
||||
string newMotto = "test";
|
||||
DateTime dateToRemove = DateTime.Now;
|
||||
repo.AddDailyMotto(userId, newMotto, dateToRemove);
|
||||
|
||||
// Act
|
||||
bool result = repo.DeleteDailyMotto(userId);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetDailyMotto_WithValidParameters_ReturnsMotto()
|
||||
{
|
||||
// Arrange
|
||||
FancierProfileRepo repo = new FancierProfileRepo();
|
||||
Guid userId = Guid.NewGuid();
|
||||
string newMotto = "test";
|
||||
DateTime dateToRemove = DateTime.Now;
|
||||
repo.AddDailyMotto(userId, newMotto, dateToRemove);
|
||||
|
||||
// Act
|
||||
string result = repo.GetDailyMotto(userId);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(newMotto, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetLinks_WithValidParameters_ReturnsLinks()
|
||||
{
|
||||
// Arrange
|
||||
FancierProfileRepo repo = new FancierProfileRepo();
|
||||
Guid userId = Guid.NewGuid();
|
||||
string linkToAdd = "www.google.com";
|
||||
repo.AddLink(userId, linkToAdd);
|
||||
|
||||
// Act
|
||||
List<string> result = repo.GetLinks(userId);
|
||||
|
||||
// Assert
|
||||
Assert.Contains(linkToAdd, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetFrameNumber_WithValidParameters_ReturnsFrameNumber()
|
||||
{
|
||||
// Arrange
|
||||
FancierProfileRepo repo = new FancierProfileRepo();
|
||||
Guid userId = Guid.NewGuid();
|
||||
int newFrameNumber = 5;
|
||||
repo.SetFrameNumber(userId, newFrameNumber);
|
||||
|
||||
// Act
|
||||
int result = repo.GetFrameNumber(userId);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(newFrameNumber, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetHashtag_WithValidParameters_ReturnsHashtag()
|
||||
{
|
||||
// Arrange
|
||||
FancierProfileRepo repo = new FancierProfileRepo();
|
||||
Guid userId = Guid.NewGuid();
|
||||
string newHashtag = "#test";
|
||||
repo.SetHashtag(userId, newHashtag);
|
||||
|
||||
// Act
|
||||
string result = repo.GetHashtag(userId);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(newHashtag, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetDailyMotto_WithInvalidParameters_ReturnsNull()
|
||||
{
|
||||
// Arrange
|
||||
FancierProfileRepo repo = new FancierProfileRepo();
|
||||
Guid userId = Guid.NewGuid();
|
||||
|
||||
// Act
|
||||
string result = repo.GetDailyMotto(userId);
|
||||
|
||||
// Assert
|
||||
Assert.Null(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetLinks_WithInvalidParameters_ReturnsNull()
|
||||
{
|
||||
// Arrange
|
||||
FancierProfileRepo repo = new FancierProfileRepo();
|
||||
Guid userId = Guid.NewGuid();
|
||||
|
||||
// Act
|
||||
List<string> result = repo.GetLinks(userId);
|
||||
|
||||
// Assert
|
||||
Assert.Null(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetFrameNumber_WithInvalidParameters_ReturnsNull()
|
||||
{
|
||||
// Arrange
|
||||
FancierProfileRepo repo = new FancierProfileRepo();
|
||||
Guid userId = Guid.NewGuid();
|
||||
|
||||
// Act
|
||||
int result = repo.GetFrameNumber(userId);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(-1, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetHashtag_WithInvalidParameters_ReturnsNull()
|
||||
{
|
||||
// Arrange
|
||||
FancierProfileRepo repo = new FancierProfileRepo();
|
||||
Guid userId = Guid.NewGuid();
|
||||
|
||||
// Act
|
||||
string result = repo.GetHashtag(userId);
|
||||
|
||||
// Assert
|
||||
Assert.Null(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
using District_3_App.Repository;
|
||||
using District_3_App.Enitities;
|
||||
|
||||
namespace District_3_App_Tests.RepositoryTests
|
||||
{
|
||||
public class HighlightsRepoTests
|
||||
{
|
||||
[Fact]
|
||||
public void AddHighlight_WithValidHighlight_ReturnsTrue()
|
||||
{
|
||||
// Arrange
|
||||
var mockHighlightsRepo = new HighlightsRepo();
|
||||
var userId = new Guid("11111111-1111-1111-1111-111111111111");
|
||||
var highlight = new Highlight("Highlight 1", "Cover 1");
|
||||
|
||||
// Act
|
||||
var result = mockHighlightsRepo.AddHighlight(userId, highlight);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RemoveHighlight_WithExistingHighlight_ReturnsTrue()
|
||||
{
|
||||
// Arrange
|
||||
var mockHighlightsRepo = new HighlightsRepo();
|
||||
var userId = new Guid("11111111-1111-1111-1111-111111111111");
|
||||
var highlight = new Highlight("Highlight 1", "Cover 1");
|
||||
var highlightId = highlight.GetHighlightId();
|
||||
mockHighlightsRepo.AddHighlight(userId, highlight);
|
||||
|
||||
// Act
|
||||
var result = mockHighlightsRepo.RemoveHighlight(userId, highlightId);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddPostToHighlight_WithValidPost_ReturnsTrue()
|
||||
{
|
||||
// Arrange
|
||||
var mockHighlightsRepo = new HighlightsRepo();
|
||||
var userId = new Guid("11111111-1111-1111-1111-111111111111");
|
||||
var highlight = new Highlight("Highlight 1", "Cover 1");
|
||||
var highlightId = highlight.GetHighlightId();
|
||||
var postId = new Guid("22222222-2222-2222-2222-222222222222");
|
||||
mockHighlightsRepo.AddHighlight(userId, highlight);
|
||||
|
||||
// Act
|
||||
var result = mockHighlightsRepo.AddPostToHighlight(userId, postId, highlightId);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RemovePostFromHighlight_WithExistingPost_ReturnsTrue()
|
||||
{
|
||||
// Arrange
|
||||
var mockHighlightsRepo = new HighlightsRepo();
|
||||
var userId = new Guid("11111111-1111-1111-1111-111111111111");
|
||||
var highlight = new Highlight("Highlight 1", "Cover 1");
|
||||
var highlightId = highlight.GetHighlightId();
|
||||
var postId = new Guid("22222222-2222-2222-2222-222222222222");
|
||||
mockHighlightsRepo.AddHighlight(userId, highlight);
|
||||
mockHighlightsRepo.AddPostToHighlight(userId, postId, highlightId);
|
||||
|
||||
// Act
|
||||
var result = mockHighlightsRepo.RemovePostFromHighlight(userId, postId, highlightId);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetHighlightsOfUser_WithValidUser_ReturnsNotNull()
|
||||
{
|
||||
// Arrange
|
||||
var mockHighlightsRepo = new HighlightsRepo();
|
||||
var userId = new Guid("11111111-1111-1111-1111-111111111111");
|
||||
var highlight = new Highlight("Highlight 1", "Cover 1");
|
||||
mockHighlightsRepo.AddHighlight(userId, highlight);
|
||||
|
||||
// Act
|
||||
var result = mockHighlightsRepo.GetHighlightsOfUser(userId);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetHighlight_WithValidHighlightId_ReturnsNotNull()
|
||||
{
|
||||
// Arrange
|
||||
var mockHighlightsRepo = new HighlightsRepo();
|
||||
var userId = new Guid("11111111-1111-1111-1111-111111111111");
|
||||
var highlight = new Highlight("Highlight 1", "Cover 1");
|
||||
var highlightId = highlight.GetHighlightId();
|
||||
mockHighlightsRepo.AddHighlight(userId, highlight);
|
||||
|
||||
// Act
|
||||
var result = mockHighlightsRepo.GetHighlight(userId, highlightId);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetPostsOfHighlight_WithValidHighlightId_ReturnsNotNull()
|
||||
{
|
||||
// Arrange
|
||||
var mockHighlightsRepo = new HighlightsRepo();
|
||||
var userId = new Guid("11111111-1111-1111-1111-111111111111");
|
||||
var highlight = new Highlight("Highlight 1", "Cover 1");
|
||||
var highlightId = highlight.GetHighlightId();
|
||||
var postId = new Guid("22222222-2222-2222-2222-222222222222");
|
||||
mockHighlightsRepo.AddHighlight(userId, highlight);
|
||||
mockHighlightsRepo.AddPostToHighlight(userId, postId, highlightId);
|
||||
|
||||
// Act
|
||||
var result = mockHighlightsRepo.GetPostsOfHighlight(userId, highlightId);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
using System;
|
||||
using District_3_App.Repository;
|
||||
using District_3_App.Enitities;
|
||||
|
||||
namespace District_3_App_Tests.RepositoryTests
|
||||
{
|
||||
public class SnapshotsRepoTests
|
||||
{
|
||||
[Fact]
|
||||
public void AddHighlight_WithValidHighlight_ReturnsTrue()
|
||||
{
|
||||
// Arrange
|
||||
var userId = Guid.NewGuid();
|
||||
var snapshotRepo = new SnapshotsRepo(userId);
|
||||
var highlight = new Highlight("highlight", "description");
|
||||
|
||||
// Act
|
||||
var result = snapshotRepo.AddHighlight(highlight);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RemoveHighlight_WithExistingHighlight_ReturnsTrue()
|
||||
{
|
||||
// Arrange
|
||||
var userId = Guid.NewGuid();
|
||||
var snapshotRepo = new SnapshotsRepo(userId);
|
||||
var highlight = new Highlight("highlight", "description");
|
||||
snapshotRepo.AddHighlight(highlight);
|
||||
|
||||
// Act
|
||||
var result = snapshotRepo.RemoveHighlight(highlight);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddPostToHighlight_WithValidPost_ReturnsFalse()
|
||||
{
|
||||
// Arrange
|
||||
var userId = Guid.NewGuid();
|
||||
var snapshotRepo = new SnapshotsRepo(userId);
|
||||
var highlight = new Highlight("highlight", "description");
|
||||
snapshotRepo.AddHighlight(highlight);
|
||||
var postId = Guid.NewGuid();
|
||||
|
||||
// Act
|
||||
var result = snapshotRepo.AddPostToHighlight(highlight.GetHighlightId(), postId);
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RemovePostFromHighlight_WithExistingPost_ReturnsFalse()
|
||||
{
|
||||
// Arrange
|
||||
var userId = Guid.NewGuid();
|
||||
var snapshotRepo = new SnapshotsRepo(userId);
|
||||
var highlight = new Highlight("highlight", "description");
|
||||
snapshotRepo.AddHighlight(highlight);
|
||||
var postId = Guid.NewGuid();
|
||||
snapshotRepo.AddPostToHighlight(highlight.GetHighlightId(), postId);
|
||||
|
||||
// Act
|
||||
var result = snapshotRepo.RemovePostFromHighlight(highlight.GetHighlightId(), postId);
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetHighlightsRepo_ReturnsNotNull()
|
||||
{
|
||||
// Arrange
|
||||
var userId = Guid.NewGuid();
|
||||
var snapshotRepo = new SnapshotsRepo(userId);
|
||||
|
||||
// Act
|
||||
var result = snapshotRepo.GetHighlightsRepo();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetHighlightsOfUser_WithValidUser_ReturnsNotNull()
|
||||
{
|
||||
// Arrange
|
||||
var userId = Guid.NewGuid();
|
||||
var snapshotRepo = new SnapshotsRepo(userId);
|
||||
var highlight = new Highlight("highlight", "description");
|
||||
snapshotRepo.AddHighlight(highlight);
|
||||
|
||||
// Act
|
||||
var result = snapshotRepo.GetHighlightsOfUser();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetHighlight_WithExistingHighlightId_ReturnsNotNull()
|
||||
{
|
||||
// Arrange
|
||||
var userId = Guid.NewGuid();
|
||||
var snapshotRepo = new SnapshotsRepo(userId);
|
||||
var highlight = new Highlight("highlight", "description");
|
||||
snapshotRepo.AddHighlight(highlight);
|
||||
|
||||
// Act
|
||||
var result = snapshotRepo.GetHighlight(highlight.GetHighlightId());
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using District_3_App.ProfileSocialNetworkInfoStuff.ProfileNetworkInfo_Repository;
|
||||
|
||||
namespace District_3_App_Tests.RepositoryTests
|
||||
{
|
||||
public class UsersRepositoryTests
|
||||
{
|
||||
|
||||
[Fact]
|
||||
public void ChangeUserPasswordTest_WithValueTrue()
|
||||
{
|
||||
// Arrange
|
||||
UsersRepository usersRepository = new UsersRepository("Users.xml");
|
||||
bool result = usersRepository.UpdatePassword("test0@yahoo.com", "test-0");
|
||||
|
||||
Assert.True(result);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ChangeUserPasswordTest_WithValueFalse()
|
||||
{
|
||||
// Arrange
|
||||
UsersRepository usersRepository = new UsersRepository("Users.xml");
|
||||
bool result = usersRepository.UpdatePassword("nuexista@yahoo.com", "newpass");
|
||||
Assert.False(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UsernameExists_WithValueTrue()
|
||||
{
|
||||
// Arrange
|
||||
UsersRepository usersRepository = new UsersRepository("Users.xml");
|
||||
bool result = usersRepository.UsernameExists("test_0");
|
||||
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UsernameExists_WithValueFalse()
|
||||
{
|
||||
// Arrange
|
||||
UsersRepository usersRepository = new UsersRepository("Users.xml");
|
||||
bool result = usersRepository.UsernameExists("test-0");
|
||||
|
||||
Assert.False(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EmailExists_WithValueTrue()
|
||||
{
|
||||
// Arrange
|
||||
UsersRepository usersRepository = new UsersRepository("Users.xml");
|
||||
bool result = usersRepository.EmailExists("test0@yahoo.com");
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EmailExists_WithValueFalse()
|
||||
{
|
||||
// Arrange
|
||||
UsersRepository usersRepository = new UsersRepository("Users.xml");
|
||||
bool result = usersRepository.EmailExists("");
|
||||
Assert.False(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user