School Commit Init

This commit is contained in:
2024-08-31 12:07:21 +03:00
commit 0b130ee18c
2801 changed files with 4720552 additions and 0 deletions
@@ -0,0 +1,39 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<RootNamespace>District_3_App_Tests</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<None Remove="UserManagerTests\Users.xml" />
</ItemGroup>
<ItemGroup>
<Content Include="UserManagerTests\Users.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\District 3 App\District 3 App.csproj" />
</ItemGroup>
<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>
</Project>
@@ -0,0 +1,54 @@
<groups>
<group groupId="c221950c-7e1d-4a17-83a7-9af616bba78d" groupName="group 1">
<members>
<user userId="d161f928-2601-4e63-be9f-c05a1399b6b3" username="username2" password="password2" email="username2@gmail.ro" confirmationPassword="password2" />
<user userId="cf9428ef-97c3-4003-9815-03942dc79da8" username="username3" password="password3" email="user3@yahoo.com" confirmationPassword="password3" />
<user userId="3b63be21-18ce-46cb-801c-0dca405c7e83" username="username1" password="password1" email="user1@yahoo.ro" confirmationPassword="password1" />
<user userId="db61df0b-f9ae-489e-8406-bc116ee26ebc" username="username5" password="password5" email="username4@gmail.es" confirmationPassword="password5" />
</members>
</group>
<group groupId="efa488bd-050b-442c-8ebb-5ae3a4d9b7e4" groupName="group 3">
<members>
<user userId="3b63be21-18ce-46cb-801c-0dca405c7e83" username="username1" password="password1" email="user1@yahoo.ro" confirmationPassword="password1" />
<user userId="55f400a6-dcdf-4763-8ab0-fd6f2d1438a3" username="username5" password="password5" email="username4@gmail.es" confirmationPassword="password5" />
<user userId="d161f928-2601-4e63-be9f-c05a1399b6b3" username="username2" password="password2" email="username2@gmail.ro" confirmationPassword="password2" />
</members>
</group>
<group groupId="487a96c4-eb2b-4eea-9ac2-ecf3458206ec" groupName="group 2">
<members>
<user userId="3b63be21-18ce-46cb-801c-0dca405c7e83" username="username1" password="password1" email="user1@yahoo.ro" confirmationPassword="password1" />
<user userId="55f400a6-dcdf-4763-8ab0-fd6f2d1438a3" username="username5" password="password5" email="username4@gmail.es" confirmationPassword="password5" />
<user userId="ad36cdfe-3a9f-4f6b-a2ce-d9a73fd4c405" username="username4" password="password4" email="username4@stud.ubbcluj.ro" confirmationPassword="password4" />
<user userId="5d0cd3c3-9f92-481c-9c6e-75830d3743a4" username="username3" password="password3" email="user3@yahoo.com" confirmationPassword="password3" />
</members>
</group>
<group groupId="df05a760-20bd-4b3f-920f-a5407ad0c25a" groupName="another group">
<members>
<user userId="55f400a6-dcdf-4763-8ab0-fd6f2d1438a3" username="username5" password="password5" email="username4@gmail.es" confirmationPassword="password5" />
<user userId="cf9428ef-97c3-4003-9815-03942dc79da8" username="username3" password="password3" email="user3@yahoo.com" confirmationPassword="password3" />
<user userId="ce7ad3bd-0b87-4122-8766-54be4cef5fe9" username="username1" password="password1" email="user1@yahoo.ro" confirmationPassword="password1" />
<user userId="ba8f4eca-daa5-4c34-af00-0ff70a022526" username="username2" password="password2" email="username2@gmail.ro" confirmationPassword="password2" />
</members>
</group>
<group groupId="4163dad5-ab81-4d26-9d02-559d04d88733" groupName="testXMLGroup">
<members>
<user userId="998e1318-0a8c-4896-9aa0-6cd64419fc78" username="username1" password="password1" email="user1@yahoo.ro" confirmationPassword="password1" />
</members>
</group>
<group groupId="14620abb-17a0-4dd3-9c7e-8aa1de3b8225" groupName="newGrouptestXML">
<members>
<user userId="51a31753-6359-47c9-82fa-b8468136e14f" username="username1" password="password1" email="user1@yahoo.ro" confirmationPassword="password1" />
</members>
</group>
<group groupId="61ffb63b-5f2d-4ef6-8a1a-d01ef83b784b" groupName="testAllXML">
<members>
<user userId="88d05d97-0cad-4ce3-a06f-be6e69d698b5" username="username1" password="password1" email="user1@yahoo.ro" confirmationPassword="password1" />
</members>
</group>
<group groupId="1ffeb77a-a4dd-437b-a561-d5a90ace73d7" groupName="THELAST___TEST">
<members>
<user userId="52e1cf6f-c1a9-4100-af4b-9eedc2172cb2" username="username1" password="password1" email="user1@yahoo.ro" confirmationPassword="password1" />
<user userId="2d793e4d-0dd3-43f4-b6d3-c3a415212b45" username="username4" password="password4" email="username4@stud.ubbcluj.ro" confirmationPassword="password4" />
</members>
</group>
</groups>
@@ -0,0 +1,14 @@
<groups>
<group groupId="444bcd67-4c42-4982-83d1-07649922b7e1" groupName="Group 1">
<members>
<user userId="6edbcbfc-c78b-4f09-93d9-ec0062635b2b" username="user1" password="password1" email="user1@example.com" confirmationPassword="password1Confirmation" />
<user userId="e8ad33cc-20ca-4272-bdf4-6a6498a38b6f" username="user2" password="password2" email="user2@example.com" confirmationPassword="password2Confirmation" />
</members>
</group>
<group groupId="6c7b308d-ba0d-4695-8f88-6a05f22ec90a" groupName="Group 2">
<members>
<user userId="e8ad33cc-20ca-4272-bdf4-6a6498a38b6f" username="user2" password="password2" email="user2@example.com" confirmationPassword="password2Confirmation" />
<user userId="d58f81be-0ed8-4e5c-a295-d2a1100b6027" username="user3" password="password3" email="user3@example.com" confirmationPassword="password3Confirmation" />
</members>
</group>
</groups>
@@ -0,0 +1,148 @@
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfUserProfileSocialNetworkInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<UserProfileSocialNetworkInfo>
<User>
<Id>283c7d8e-1d05-4ff0-96c7-1b24c4a58c26</Id>
<Username>user1</Username>
<Password>password1</Password>
<Email>user1@example.com</Email>
<ConfirmationPassword>password1Confirmation</ConfirmationPassword>
<RegistrationDate>0001-01-01T00:00:00</RegistrationDate>
<FollowingCount>0</FollowingCount>
<FollowersCount>0</FollowersCount>
<Usersession>PT0S</Usersession>
</User>
<BlockedProfiles>
<BlockedProfile>
<User>
<Id>8a5dfcd2-00b2-4ede-8384-1af9cc2b388d</Id>
<Username>black_ship</Username>
<Password>password4</Password>
<Email>user4@example.com</Email>
<ConfirmationPassword>password4Confirmation</ConfirmationPassword>
<RegistrationDate>0001-01-01T00:00:00</RegistrationDate>
<FollowingCount>0</FollowingCount>
<FollowersCount>0</FollowersCount>
<Usersession>PT0S</Usersession>
</User>
<BlockDate>2024-04-24T02:26:10.1633005+03:00</BlockDate>
</BlockedProfile>
</BlockedProfiles>
<CloseFriendsProfiles />
<Groups>
<Group>
<Id>104c553b-03b7-467c-9c3c-7273fa64b3bf</Id>
<GroupName>Group 1</GroupName>
<GroupMembers>
<User>
<Id>283c7d8e-1d05-4ff0-96c7-1b24c4a58c26</Id>
<Username>user1</Username>
<Password>password1</Password>
<Email>user1@example.com</Email>
<ConfirmationPassword>password1Confirmation</ConfirmationPassword>
<RegistrationDate>0001-01-01T00:00:00</RegistrationDate>
<FollowingCount>0</FollowingCount>
<FollowersCount>0</FollowersCount>
<Usersession>PT0S</Usersession>
</User>
<User>
<Id>2ae09055-6ac0-4a42-bc0a-e6570bbb457b</Id>
<Username>user2</Username>
<Password>password2</Password>
<Email>user2@example.com</Email>
<ConfirmationPassword>password2Confirmation</ConfirmationPassword>
<RegistrationDate>0001-01-01T00:00:00</RegistrationDate>
<FollowingCount>0</FollowingCount>
<FollowersCount>0</FollowersCount>
<Usersession>PT0S</Usersession>
</User>
</GroupMembers>
</Group>
</Groups>
<RestrictedStoriesAudience />
<RestrictedPostsAudience />
<IsProfilePrivate>false</IsProfilePrivate>
</UserProfileSocialNetworkInfo>
<UserProfileSocialNetworkInfo>
<User>
<Id>2ae09055-6ac0-4a42-bc0a-e6570bbb457b</Id>
<Username>user2</Username>
<Password>password2</Password>
<Email>user2@example.com</Email>
<ConfirmationPassword>password2Confirmation</ConfirmationPassword>
<RegistrationDate>0001-01-01T00:00:00</RegistrationDate>
<FollowingCount>0</FollowingCount>
<FollowersCount>0</FollowersCount>
<Usersession>PT0S</Usersession>
</User>
<BlockedProfiles />
<CloseFriendsProfiles />
<Groups>
<Group>
<Id>72edb06b-913d-4299-adfe-b5949a664531</Id>
<GroupName>Group 2</GroupName>
<GroupMembers>
<User>
<Id>2ae09055-6ac0-4a42-bc0a-e6570bbb457b</Id>
<Username>user2</Username>
<Password>password2</Password>
<Email>user2@example.com</Email>
<ConfirmationPassword>password2Confirmation</ConfirmationPassword>
<RegistrationDate>0001-01-01T00:00:00</RegistrationDate>
<FollowingCount>0</FollowingCount>
<FollowersCount>0</FollowersCount>
<Usersession>PT0S</Usersession>
</User>
<User>
<Id>0571f7ff-7068-44f1-b93c-0aa625276329</Id>
<Username>user3</Username>
<Password>password3</Password>
<Email>user3@example.com</Email>
<ConfirmationPassword>password3Confirmation</ConfirmationPassword>
<RegistrationDate>0001-01-01T00:00:00</RegistrationDate>
<FollowingCount>0</FollowingCount>
<FollowersCount>0</FollowersCount>
<Usersession>PT0S</Usersession>
</User>
</GroupMembers>
</Group>
</Groups>
<RestrictedStoriesAudience />
<RestrictedPostsAudience />
<IsProfilePrivate>false</IsProfilePrivate>
</UserProfileSocialNetworkInfo>
<UserProfileSocialNetworkInfo>
<User>
<Id>0571f7ff-7068-44f1-b93c-0aa625276329</Id>
<Username>user3</Username>
<Password>password3</Password>
<Email>user3@example.com</Email>
<ConfirmationPassword>password3Confirmation</ConfirmationPassword>
<RegistrationDate>0001-01-01T00:00:00</RegistrationDate>
<FollowingCount>0</FollowingCount>
<FollowersCount>0</FollowersCount>
<Usersession>PT0S</Usersession>
</User>
<BlockedProfiles />
<CloseFriendsProfiles />
<Groups />
<RestrictedStoriesAudience />
<RestrictedPostsAudience />
<IsProfilePrivate>false</IsProfilePrivate>
</UserProfileSocialNetworkInfo>
<UserProfileSocialNetworkInfo>
<User>
<Id>00000000-0000-0000-0000-000000000000</Id>
<RegistrationDate>0001-01-01T00:00:00</RegistrationDate>
<FollowingCount>0</FollowingCount>
<FollowersCount>0</FollowersCount>
<Usersession>PT0S</Usersession>
</User>
<BlockedProfiles />
<CloseFriendsProfiles />
<Groups />
<RestrictedStoriesAudience />
<RestrictedPostsAudience />
<IsProfilePrivate>false</IsProfilePrivate>
</UserProfileSocialNetworkInfo>
</ArrayOfUserProfileSocialNetworkInfo>
@@ -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);
}
}
}
@@ -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);
}
}
}
@@ -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);
}
}
}
@@ -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);
}
}
}
@@ -0,0 +1,83 @@
using District_3_App.Service;
using District_3_App.Enitities.Mocks;
namespace District_3_App_Tests.ServiceTests
{
public class CasualProfileServiceTests
{
[Fact]
public void GetConnectedUserId_ReturnsGuid()
{
// Arrange
var casualProfileService = new CasualProfileService();
// Act
var result = casualProfileService.GetConnectedUserId();
// Assert
Assert.IsType<Guid>(result);
}
[Fact]
public void GetConnectedUserPosts_ReturnsListOfMockPhotoPosts()
{
// Arrange
var casualProfileService = new CasualProfileService();
// Act
var result = casualProfileService.GetConnectedUserPosts();
// Assert
Assert.IsType<List<MockPhotoPost>>(result);
}
[Fact]
public void GetSnapshotsService_ReturnsSnapshotsService()
{
// Arrange
var casualProfileService = new CasualProfileService();
// Act
var result = casualProfileService.GetSnapshotsService();
// Assert
Assert.IsType<SnapshotsService>(result);
}
[Fact]
public void GetProfileInfoSettings_ReturnsProfileInfoSettings()
{
// Arrange
var casualProfileService = new CasualProfileService();
// Act
var result = casualProfileService.GetProfileInfoSettings();
// Assert
Assert.IsType<ProfileInfoSettings>(result);
}
[Fact]
public void GetConnectedUserPosts_WhenNoPosts_ReturnsNull()
{
// Arrange
var casualProfileService = new CasualProfileService();
// Act
var result = casualProfileService.GetConnectedUserPosts1();
// Assert
Assert.Null(result);
}
[Fact]
public void CasualProfileService_CanBeInstantiated()
{
// Arrange
var casualProfileService = new CasualProfileService();
// Assert
Assert.NotNull(casualProfileService);
}
}
}
@@ -0,0 +1,181 @@
using District_3_App.Service;
namespace District_3_App_Tests.ServiceTests
{
public class ProfileInfoSettingsTests
{
[Fact]
public void AddDailyMotto_WithValidInput_ReturnsTrue()
{
// Arrange
var profileId = Guid.NewGuid();
var profileInfoSettings = new ProfileInfoSettings(profileId);
var newMotto = "newMotto";
// Act
var result = profileInfoSettings.AddDailyMotto(newMotto);
// Assert
Assert.True(result);
}
[Fact]
public void AddLink_WithValidUrl_ReturnsTrue()
{
// Arrange
var profileId = Guid.NewGuid();
var profileInfoSettings = new ProfileInfoSettings(profileId);
var newLink = "http://www.newLink.com";
// Act
var result = profileInfoSettings.AddLink(newLink);
// Assert
Assert.True(result);
}
[Fact]
public void SetFrameNumber_WithValidInput_ReturnsTrue()
{
// Arrange
var profileId = Guid.NewGuid();
var profileInfoSettings = new ProfileInfoSettings(profileId);
var newFrameNumber = 1;
// Act
var result = profileInfoSettings.SetFrameNumber(newFrameNumber);
// Assert
Assert.True(result);
}
[Fact]
public void GetFrameNumber_ReturnsNonNull()
{
// Arrange
var profileId = Guid.NewGuid();
var profileInfoSettings = new ProfileInfoSettings(profileId);
// Act
var result = profileInfoSettings.GetFrameNumber();
// Assert
Assert.NotNull(result);
}
[Fact]
public void SetHashtag_WithValidInput_ReturnsTrue()
{
// Arrange
var profileId = Guid.NewGuid();
var profileInfoSettings = new ProfileInfoSettings(profileId);
var newHashtag = "#newHashtag";
// Act
var result = profileInfoSettings.SetHashtag(newHashtag);
// Assert
Assert.True(result);
}
[Fact]
public void AddLink_WithInvalidLink_ReturnsFalse()
{
// Arrange
var profileId = Guid.NewGuid();
var profileInfoSettings = new ProfileInfoSettings(profileId);
var invalidLink = "invalidLink";
// Act
var result = profileInfoSettings.AddLink(invalidLink);
// Assert
Assert.False(result);
}
[Fact]
public void DeleteLink_WithInvalidLink_ReturnsFalse()
{
// Arrange
var profileId = Guid.NewGuid();
var profileInfoSettings = new ProfileInfoSettings(profileId);
var linkToDelete = "invalidLink";
// Act
var result = profileInfoSettings.DeleteLink(linkToDelete);
// Assert
Assert.False(result);
}
[Fact]
public void DeleteFrameNumber_WithInvalidFrameNumber_ReturnsFalse()
{
// Arrange
var profileId = Guid.NewGuid();
var profileInfoSettings = new ProfileInfoSettings(profileId);
// Act
var result = profileInfoSettings.DeleteFrameNumber();
// Assert
Assert.False(result);
}
[Fact]
public void DeleteHashtag_WithInvalidHashtag_ReturnsFalse()
{
// Arrange
var profileId = Guid.NewGuid();
var profileInfoSettings = new ProfileInfoSettings(profileId);
// Act
var result = profileInfoSettings.DeleteHashtag();
// Assert
Assert.False(result);
}
[Fact]
public void GetDailyMotto_WhenMottoNotSet_ReturnsNull()
{
// Arrange
var profileId = Guid.NewGuid();
var profileInfoSettings = new ProfileInfoSettings(profileId);
// Act
var result = profileInfoSettings.GetDailyMotto();
// Assert
Assert.Null(result);
}
[Fact]
public void GetLinks_WithNoLinks_ReturnsNull()
{
// Arrange
var profileId = Guid.NewGuid();
var profileInfoSettings = new ProfileInfoSettings(profileId);
// Act
var result = profileInfoSettings.GetLinks();
// Assert
Assert.Null(result);
}
[Fact]
public void GetHashtag_WhenNoHashtagSet_ReturnsNull()
{
// Arrange
var profileId = Guid.NewGuid();
var profileInfoSettings = new ProfileInfoSettings(profileId);
// Act
var result = profileInfoSettings.GetHashtag();
// Assert
Assert.Null(result);
}
}
}
@@ -0,0 +1,95 @@
using District_3_App.Service;
using District_3_App.Enitities;
namespace District_3_App_Tests.ServiceTests
{
public class SnapshotsServiceTests
{
[Fact]
public void AddHighlight_WithValidDetails_ReturnsTrue()
{
// Arrange
var snapshotsService = new SnapshotsService(Guid.NewGuid());
var newHighlightName = "Highlight_1";
var newHighlightCover = "cover";
var guids = new List<Guid> { Guid.NewGuid() };
// Act
var result = snapshotsService.AddHighlight(newHighlightName, newHighlightCover, guids);
// Assert
Assert.True(result);
}
[Fact]
public void RemoveHighlight_WithNonExistentHighlight_ReturnsFalse()
{
// Arrange
var snapshotsService = new SnapshotsService(Guid.NewGuid());
var highlight = new Highlight("Highlight_1", "cover");
// Act
var result = snapshotsService.RemoveHighlight(highlight);
// Assert
Assert.False(result);
}
[Fact]
public void AddPostToHighlight_WithNonExistentHighlight_ReturnsFalse()
{
// Arrange
var snapshotsService = new SnapshotsService(Guid.NewGuid());
var highlightId = Guid.NewGuid();
var postId = Guid.NewGuid();
// Act
var result = snapshotsService.AddPostToHighlight(highlightId, postId);
// Assert
Assert.False(result);
}
[Fact]
public void RemovePostFromHighlight_WithNonExistentHighlight_ReturnsFalse()
{
// Arrange
var snapshotsService = new SnapshotsService(Guid.NewGuid());
var highlightId = Guid.NewGuid();
var postId = Guid.NewGuid();
// Act
var result = snapshotsService.RemovePostFromHighlight(highlightId, postId);
// Assert
Assert.False(result);
}
[Fact]
public void GetHighlightsOfUser_WithValidUser_ReturnsNonNull()
{
// Arrange
var snapshotsService = new SnapshotsService(Guid.NewGuid());
// Act
var result = snapshotsService.GetHighlightsOfUser();
// Assert
Assert.NotNull(result);
}
[Fact]
public void GetPostsOfHighlight_WithValidHighlight_ReturnsNonNull()
{
// Arrange
var snapshotsService = new SnapshotsService(Guid.NewGuid());
var highlightId = Guid.NewGuid();
// Act
var result = snapshotsService.GetPostsOfHighlight(highlightId);
// Assert
Assert.NotNull(result);
}
}
}
@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using District_3_App.LogIn;
using Xunit;
namespace District_3_App_Tests.UserManagerTests
{
public class UserManagerTests
{
[Fact]
public void AuthenticateUser_WithValidParameters_ReturnsTrue()
{
UserManager userManager = new UserManager("Users.xml");
string username=userManager.GetCurrentUser();
Assert.Equal("",username);
Assert.False(userManager.IsUserLoggedIn());
bool result=userManager.AuthenticateUser("test_1", "Test-1");
Assert.True(result);
Assert.True(userManager.IsUserLoggedIn());
}
[Fact]
public void AuthnticateUser_WithInvalidParameters_ReturnsFalse()
{
UserManager userManager = new UserManager("Users.xml");
string username=userManager.GetCurrentUser();
Assert.Equal("",username);
Assert.False(userManager.IsUserLoggedIn());
bool result=userManager.AuthenticateUser("test-1", "Test-2");
Assert.False(result);
Assert.False(userManager.IsUserLoggedIn());
}
[Fact]
public void LogOutUser_WithValidParameters_ReturnsTrue()
{
UserManager userManager = new UserManager("Users.xml");
string username=userManager.GetCurrentUser();
Assert.Equal("",username);
Assert.False(userManager.IsUserLoggedIn());
bool result=userManager.AuthenticateUser("test_1", "Test-1");
Assert.True(result);
Assert.True(userManager.IsUserLoggedIn());
userManager.LogOutUser();
Assert.False(userManager.IsUserLoggedIn());
}
}
}
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<UserAccounts>
<User id="f641b016-0e18-4f35-898c-c6016fe034f4" Username="test_0" Email="test0@yahoo.com" Password="Test-9" ConfirmationPassword="Test-9">
<Following>100</Following>
<Followers>103</Followers>
</User>
<User id="11111111-1111-1111-1111-111111111111" Username="test_1" Email="test1@yahoo.com" Password="Test-1" ConfirmationPassword="Test-1">
<Following>100</Following>
<Followers>103</Followers>
</User>
<User id="22222222-2222-2222-2222-222222222222" Username="test_2" Email="test2@yahoo.com" Password="Test-2" ConfirmationPassword="Test-2">
<Following>100</Following>
<Followers>103</Followers>
</User>
<User id="33333333-3333-3333-3333-333333333333" Username="test_3" Email="test3@gmail.com" Password="Test-3" ConfirmationPassword="Test-3">
<Following>100</Following>
<Followers>103</Followers>
</User>
<User id="2e004b4a-7edc-412f-bd75-03fd52fd26cc" Username="Dia_3" Email="dia_3@gmail.com" Password="" ConfirmationPassword="">
<Following>0</Following>
<Followers>0</Followers>
</User>
<User id="985ce773-e4fd-4669-a044-da27b864ce6b" Username="usernamenou_1" Email="usrnamenou_1@gmail.com" Password="" ConfirmationPassword="">
<Following>0</Following>
<Followers>0</Followers>
</User>
<User id="dd35483f-494f-4069-aecd-0fb7fd6530a8" Username="incercam_iar_1" Email="incercarenaspa@yahoo.com" Password="diana" ConfirmationPassword="diana">
<Following>0</Following>
<Followers>0</Followers>
</User>
<User id="1f9122c6-9951-4cb9-abe7-1a30c44820da" Username="user_8" Email="user8@yahoo.com" Password="User-8" ConfirmationPassword="User-8">
<Following>0</Following>
<Followers>0</Followers>
</User>
<User id="00d98515-354e-4cb2-8027-f62b8c36bb4f" Username="user_9" Email="user9@yahoo.com" Password="User-9" ConfirmationPassword="User-9">
<Following>0</Following>
<Followers>0</Followers>
</User>
<User id="5ba53b90-4a52-4679-94a9-17d450f353aa" Username="papushika_th4" Email="kitt98@gmail.com" Password="asdfg" ConfirmationPassword="asdfg">
<Following>0</Following>
<Followers>0</Followers>
</User>
<User id="53efaecf-df10-4619-a378-5fb40687aff8" Username="diana.herta.5" Email="dialarisa@gmail.com" Password="as" ConfirmationPassword="as">
<Following>0</Following>
<Followers>0</Followers>
</User>
<User id="1b5e128a-059b-448f-a868-a7b040108676" Username="astamerge_bric1" Email="vaziceu@gmail.com" Password="haha" ConfirmationPassword="haha">
<Following>0</Following>
<Followers>0</Followers>
</User>
<User id="67f6d047-c498-4297-875d-dacf7d5fbb68" Username="NOASTAM3RE_BN" Email="hihi@gmail.com" Password="yyy" ConfirmationPassword="yyy">
<Following>0</Following>
<Followers>0</Followers>
</User>
</UserAccounts>