public void Find_RequestForFindAccount_FindAccount() { var accountSettingsStub = new[] { new AccountSettingsItem() { Login = expectedLogin, ServerName = expectedServerName, Token = expectedToken }, new AccountSettingsItem() { Login = "******", ServerName = "Tandex", Token = "9875452" }, }; _mockAccountSettings.SetupGet(settings => settings.LoadAccounts()).Returns(accountSettingsStub); _accountRegistry = new AccountRegistry(_mockAccountSettings.Object, _accountContainerStub); _accountRegistry.Load(); IAccountProjection accountFound = _accountRegistry.Find(expectedLogin); _mockAccount.VerifySet(acc => acc.Login, expectedLogin, Occurred.Once()); _mockAccount.VerifySet(acc => acc.Token, expectedToken, Occurred.Once()); Assert.AreEqual(expectedLogin, accountFound.Login); Assert.AreEqual(expectedServerName, accountFound.ServerName); Assert.AreEqual(expectedToken, accountFound.Token); Assert.IsNotNull(accountFound); }
public static WebApplication ConfigureMakeTransferEndpoint ( WebApplication app, Validator <MakeTransfer> validate, AccountRegistry accounts ) { Func <Guid, Task <Validation <AccountProcess> > > getAccountVal = id => accounts.Lookup(id) .Map(opt => opt.ToValidation(Errors.UnknownAccountId(id))); return(app.MapPost("/Transfer/Make", (MakeTransfer transfer) => { Task <Validation <AccountState> > outcome = from cmd in Async(validate(transfer)) from acc in getAccountVal(cmd.DebitedAccountId) from result in acc.Handle(cmd) select result.NewState; return outcome.Map( Faulted: ex => InternalServerError(Errors.UnexpectedError), Completed: val => val.Match( Invalid: errs => BadRequest(new { Errors = errs }), Valid: newState => Ok(new { Balance = newState.Balance }))); })); }
public void Load_RequestForLoadSetting_LoadSettings() { var accountSettingsStub = new[] { new AccountSettingsItem() { Login = expectedLogin, ServerName = expectedServerName, Token = expectedToken }, }; _mockAccountSettings.SetupGet(settings => settings.LoadAccounts()).Returns(accountSettingsStub); _accountRegistry = new AccountRegistry(_mockAccountSettings.Object, _accountContainerStub); _accountRegistry.LoadedEvent += (o, e) => { Assert.IsNotNull(e.Accounts); Assert.AreEqual(e.Accounts.Length, 1); _mockAccount.Verify(acc => acc.LoadConnector(expectedServerName), Occurred.Once()); _mockAccount.VerifySet(acc => acc.Login, expectedLogin, Occurred.Once()); _mockAccount.VerifySet(acc => acc.Token, expectedToken, Occurred.Once()); Assert.AreEqual(e.Size, expectedSize); }; _accountRegistry.Load(); }
public void SetUp() { _player = Fixture.Create <IPlayer>(); _expectedAccount = Fixture.Create <IAccount>(); _mockAccountFactory = GivenMockAccountFactoryThatCreates(_expectedAccount); _accountRegistry = Fixture.Create <AccountRegistry>(); }
public void setup() { reg = AccountRegistry.Instance; broker = new AuthenticationBroker(); // new voter reg.AddUser(new Voter("test", "password", true, "", "", new DateTime())); // new admin reg.AddUser(new Admin("admin", "password")); }
public void Registry_RequestForRegistrationAccount_RegistryAccount() { _mockAccountSettings.SetupGet(settings => settings.LoadAccounts()).Returns(Array.Empty <IAccountSettingsItem>()); _accountRegistry = new AccountRegistry(_mockAccountSettings.Object, _accountContainerStub); _accountRegistry.Registry(_mockAccount.Object); Assert.AreEqual(_accountRegistry.Size, expectedSize); IAccountProjection accountFound = _accountRegistry.Find(expectedLogin); Assert.IsNotNull(accountFound); }
public void Delete_RequestForDeletion_DeleteAccount() { _mockAccountSettings.SetupGet(settings => settings.LoadAccounts()).Returns(Array.Empty <IAccountSettingsItem>()); _accountRegistry = new AccountRegistry(_mockAccountSettings.Object, _accountContainerStub); _accountRegistry.Registry(_mockAccount.Object); Assert.IsTrue(_accountRegistry.Delete(expectedLogin)); Assert.AreEqual(_accountRegistry.Size, new SpaceSize()); IAccountProjection accountFound = _accountRegistry.Find(expectedLogin); Assert.IsNull(accountFound); }
public void SaveSettings_RequestForSaveSettings_SaveSettings() { var expectedAccountSettings = new[] { new AccountSettingsItem() { Login = expectedLogin, ServerName = expectedServerName, Token = expectedToken } }; _mockAccountSettings.SetupGet(settings => settings.LoadAccounts()).Returns(Array.Empty <IAccountSettingsItem>()); _accountRegistry = new AccountRegistry(_mockAccountSettings.Object, _accountContainerStub); _accountRegistry.Registry(_mockAccount.Object); _mockAccountSettings.Verify(settings => settings.SaveAccounts(Param.Is <IAccountSettingsItem[]>(items => items.SequenceEqual(expectedAccountSettings))), Occurred.Once()); }