Skip to content

Commit

Permalink
#75
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoEcker committed Nov 5, 2021
1 parent 590ad6e commit b528f52
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 6 deletions.
56 changes: 55 additions & 1 deletion Estimator/Estimator.Tests/Pages/CreateRoomTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,60 @@
namespace Estimator.Tests.Pages
using Estimator.Pages;
using Xunit;

namespace Estimator.Tests.Pages
{
public class CreateRoomTests
{
[Theory]
[InlineData("Max Mustermann", false)]
[InlineData("", true)]
public void IsParameterEmptyTest(string userName, bool isUsernameEmpty)
{
#region Assign

var creatRoom = new CreateRoom();

creatRoom.Username = userName;

#endregion

#region Act

var result = creatRoom.IsUsernameEmpty();

#endregion

#region Assert

Assert.Equal(isUsernameEmpty, result);

#endregion
}

[Theory]
[InlineData("Fibonacci", 1)]
[InlineData("T-Shirt", 2)]
[InlineData("Test", 2)]
public void ConvertTypeTest(string type , int convertType)
{
#region Assign

var creatRoom = new CreateRoom();

#endregion

#region Act

var result = creatRoom.ConvertType(type);

#endregion

#region Assert

Assert.Equal(convertType, result);

#endregion
}

}
}
34 changes: 33 additions & 1 deletion Estimator/Estimator.Tests/Pages/JoinRoomTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
namespace Estimator.Tests.Pages
using System;
using Estimator.Data;
using Estimator.Pages;
using Xunit;

namespace Estimator.Tests.Pages
{
public class JoinRoomTests
{
[Theory]
[InlineData("12345", "Max Mustermann", false)]
[InlineData("", "", true)]
[InlineData("123456", "", true)]
public void IsParameterEmptyTest(string roomId, string userName, bool isParameterEmpty)
{
#region Assign

var joinRoom = new JoinRoom();

joinRoom.RoomId = roomId;
joinRoom.Username = userName;

#endregion

#region Act

var result = joinRoom.IsParameterEmpty();

#endregion

#region Assert

Assert.Equal(isParameterEmpty, result);

#endregion
}
}
}
12 changes: 10 additions & 2 deletions Estimator/Estimator/Pages/CreateRoom.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
using Microsoft.JSInterop;
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Estimator.Data.Interface;

[assembly: InternalsVisibleTo("Estimator.Tests.Pages")]

namespace Estimator.Pages
{
public partial class CreateRoom
Expand All @@ -20,7 +23,7 @@ public partial class CreateRoom

private async void CreateNewRoom()
{
if (this.Username == string.Empty)
if (this.IsUsernameEmpty())
{
await this.Alert("Please enter a username!");
return;
Expand All @@ -41,7 +44,12 @@ private async void CreateNewRoom()
}
}

private int ConvertType(string type)
internal bool IsUsernameEmpty()
{
return this.Username == String.Empty;
}

internal int ConvertType(string type)
{
return type == "Fibonacci" ? 1 : 2;
}
Expand Down
12 changes: 10 additions & 2 deletions Estimator/Estimator/Pages/JoinRoom.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;

[assembly: InternalsVisibleTo("Estimator.Tests.Pages")]

namespace Estimator.Pages
{
public partial class JoinRoom
Expand All @@ -13,9 +16,10 @@ public partial class JoinRoom

private async void JoinRoomById()
{
if (this.Username.Equals(string.Empty) || this.RoomId.Equals(string.Empty))

if(this.IsParameterEmpty())
{
await this.Alert("Username or RoomId is empty!");
await Alert("Username or RoomId is empty!");
return;
}

Expand All @@ -37,6 +41,10 @@ private async void JoinRoomById()
await this.Alert("Something went wrong!");
}
}
internal bool IsParameterEmpty()
{
return this.Username.Equals(string.Empty) || this.RoomId.Equals(string.Empty);
}

private async Task Alert(string alertMessage)
{
Expand Down

0 comments on commit b528f52

Please # to comment.