-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PAGE text variable, create SessionEnum extension (#409)
* Add Text_Variables * Add Unknown to test * Add Text Variables * Add create date * Merge changes * remove unneeded comments * Fixed credat * Fixed test * Fixed hard coded date * fix usings * reduce code * Add Extension Unit Tests * Add PAGE text variable, create SessionEnum extension *Added PAGE text variable *Moved SessionEnum logic out of UsersOnline and created extension for use in other places * Add Unit Tests for new extension
- Loading branch information
Showing
4 changed files
with
166 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using MBBSEmu.Extensions; | ||
using MBBSEmu.Session.Enums; | ||
using Xunit; | ||
|
||
namespace MBBSEmu.Tests.Extensions | ||
{ | ||
public class EnumSessionState_Tests | ||
{ | ||
[Theory] | ||
[InlineData(EnumSessionState.EnteringFullScreenEditor, "", "", true, true)] | ||
[InlineData(EnumSessionState.ExitingFullScreenDisplay, "", "", true, true)] | ||
[InlineData(EnumSessionState.InFullScreenDisplay, "", "", true, true)] | ||
[InlineData(EnumSessionState.InFullScreenEditor, "", "", true, true)] | ||
[InlineData(EnumSessionState.EnteringModule, "", "", true, true)] | ||
[InlineData(EnumSessionState.RloginEnteringModule, "", "", true, true)] | ||
[InlineData(EnumSessionState.InModule, "", "", true, true)] | ||
[InlineData(EnumSessionState.LoginRoutines, "", "Main Menu", true, false)] | ||
[InlineData(EnumSessionState.MainMenuDisplay, "", "Main Menu", true, false)] | ||
[InlineData(EnumSessionState.MainMenuInput, "", "Main Menu", true, false)] | ||
[InlineData(EnumSessionState.MainMenuInputDisplay, "", "Main Menu", true, false)] | ||
[InlineData(EnumSessionState.ExitingModule, "", "Main Menu", true, false)] | ||
[InlineData(EnumSessionState.SignupUsernameInput, "<<New User>>", "New User Sign-up", false, false)] | ||
[InlineData(EnumSessionState.SignupUsernameDisplay, "<<New User>>", "New User Sign-up", false, false)] | ||
[InlineData(EnumSessionState.SignupEmailDisplay, "<<New User>>", "New User Sign-up", false, false)] | ||
[InlineData(EnumSessionState.SignupEmailInput, "<<New User>>", "New User Sign-up", false, false)] | ||
[InlineData(EnumSessionState.SignupPasswordDisplay, "<<New User>>", "New User Sign-up", false, false)] | ||
[InlineData(EnumSessionState.SignupPasswordInput, "<<New User>>", "New User Sign-up", false, false)] | ||
[InlineData(EnumSessionState.SignupPasswordConfirm, "<<New User>>", "New User Sign-up", false, false)] | ||
[InlineData(EnumSessionState.SignupPasswordConfirmDisplay, "<<New User>>", "New User Sign-up", false, false)] | ||
[InlineData(EnumSessionState.SignupPasswordConfirmInput, "<<New User>>", "New User Sign-up", false, false)] | ||
[InlineData(EnumSessionState.Negotiating, "<<Logging In>>", "User Login", false, false)] | ||
[InlineData(EnumSessionState.Unauthenticated, "<<Logging In>>", "User Login", false, false)] | ||
[InlineData(EnumSessionState.LoginPasswordDisplay, "<<Logging In>>", "User Login", false, false)] | ||
[InlineData(EnumSessionState.LoginPasswordInput, "<<Logging In>>", "User Login", false, false)] | ||
[InlineData(EnumSessionState.LoginUsernameDisplay, "<<Logging In>>", "User Login", false, false)] | ||
[InlineData(EnumSessionState.LoginUsernameInput, "<<Logging In>>", "User Login", false, false)] | ||
[InlineData(EnumSessionState.LoggingOffDisplay, "", "Logging Off", true, false)] | ||
[InlineData(EnumSessionState.LoggingOffProcessing, "", "Logging Off", true, false)] | ||
[InlineData(EnumSessionState.LoggedOff, "", "Logging Off", true, false)] | ||
[InlineData(EnumSessionState.ConfirmLogoffInput, "", "Logging Off", true, false)] | ||
[InlineData(EnumSessionState.ConfirmLogoffDisplay, "", "Logging Off", true, false)] | ||
[InlineData(EnumSessionState.Disconnected, "*UNKNOWN*", "*UNKNOWN*", false, false)] | ||
public void EnumSessionState_Test(EnumSessionState srcSessionState, string expUserName, string expUserOptionSelected, bool expUserSession, bool expModuleSession) | ||
{ | ||
var srcSessionInfo = srcSessionState.GetSessionState(); | ||
|
||
//Verify Results | ||
Assert.Equal(expUserName, srcSessionInfo.userName); | ||
Assert.Equal(expUserOptionSelected, srcSessionInfo.UserOptionSelected); | ||
Assert.Equal(expUserSession, srcSessionInfo.userSession); | ||
Assert.Equal(expModuleSession, srcSessionInfo.moduleSession); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
using MBBSEmu.Session.Enums; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace MBBSEmu.Extensions | ||
{ | ||
public static class EnumSessionStateExtensions | ||
{ | ||
/// <summary> | ||
/// Helper Method to determine a friendly description for EnumSessionState | ||
/// </summary> | ||
/// <param name="b"></param> | ||
/// <returns></returns> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static (string userName, string UserOptionSelected, bool userSession, bool moduleSession) GetSessionState(this EnumSessionState b) | ||
{ | ||
string userName; | ||
string userOptionSelected; | ||
bool userSession; | ||
bool moduleSession; | ||
|
||
switch (b) | ||
{ | ||
case EnumSessionState.EnteringFullScreenDisplay: | ||
case EnumSessionState.EnteringFullScreenEditor: | ||
case EnumSessionState.ExitingFullScreenDisplay: | ||
case EnumSessionState.InFullScreenDisplay: | ||
case EnumSessionState.InFullScreenEditor: | ||
case EnumSessionState.EnteringModule: | ||
case EnumSessionState.RloginEnteringModule: | ||
case EnumSessionState.InModule: | ||
userName = ""; | ||
userSession = true; | ||
userOptionSelected = ""; | ||
moduleSession = true; | ||
break; | ||
case EnumSessionState.LoginRoutines: | ||
case EnumSessionState.MainMenuDisplay: | ||
case EnumSessionState.MainMenuInput: | ||
case EnumSessionState.MainMenuInputDisplay: | ||
case EnumSessionState.ExitingModule: | ||
userName = ""; | ||
userSession = true; | ||
userOptionSelected = "Main Menu"; | ||
moduleSession = false; | ||
break; | ||
case EnumSessionState.SignupUsernameInput: | ||
case EnumSessionState.SignupUsernameDisplay: | ||
case EnumSessionState.SignupEmailDisplay: | ||
case EnumSessionState.SignupEmailInput: | ||
case EnumSessionState.SignupPasswordDisplay: | ||
case EnumSessionState.SignupPasswordInput: | ||
case EnumSessionState.SignupPasswordConfirm: | ||
case EnumSessionState.SignupPasswordConfirmDisplay: | ||
case EnumSessionState.SignupPasswordConfirmInput: | ||
userName = "<<New User>>"; | ||
userSession = false; | ||
userOptionSelected = "New User Sign-up"; | ||
moduleSession = false; | ||
break; | ||
case EnumSessionState.Negotiating: | ||
case EnumSessionState.Unauthenticated: | ||
case EnumSessionState.LoginPasswordDisplay: | ||
case EnumSessionState.LoginPasswordInput: | ||
case EnumSessionState.LoginUsernameDisplay: | ||
case EnumSessionState.LoginUsernameInput: | ||
userName = "<<Logging In>>"; | ||
userSession = false; | ||
userOptionSelected = "User Login"; | ||
moduleSession = false; | ||
break; | ||
case EnumSessionState.LoggingOffDisplay: | ||
case EnumSessionState.LoggingOffProcessing: | ||
case EnumSessionState.LoggedOff: | ||
case EnumSessionState.ConfirmLogoffInput: | ||
case EnumSessionState.ConfirmLogoffDisplay: | ||
userName = ""; | ||
userSession = true; | ||
userOptionSelected = "Logging Off"; | ||
moduleSession = false; | ||
break; | ||
default: | ||
userName = "*UNKNOWN*"; | ||
userSession = false; | ||
userOptionSelected = "*UNKNOWN*"; //Default Value | ||
moduleSession = false; | ||
break; | ||
} | ||
|
||
return (userName, userOptionSelected, userSession, moduleSession); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters