public void TestSave() { var terminalSettings = new TerminalSettingsStateModel { Command = Command, Arguments = Arguments }; var repositoryMock = new Mock <IRepository <TerminalSettings> >(); repositoryMock .Setup(m => m.Upsert(It.IsAny <string>(), It.Is <TerminalSettings>(t => t.Arguments == terminalSettings.Arguments && t.Command == terminalSettings.Command))) .Verifiable(); var uowMock = new Mock <IUnitOfWork>(); uowMock .Setup(m => m.GetRepository <TerminalSettings>()) .Returns(repositoryMock.Object); _autoMocker .Setup <IUnitOfWorkFactory, IUnitOfWork>(m => m.Create()) .Returns(uowMock.Object); var terminalService = _autoMocker.CreateInstance <TerminalService>(); terminalService.SetTerminalSettings(terminalSettings); repositoryMock.Verify(m => m.Upsert(It.IsAny <string>(), It.Is <TerminalSettings>(t => t.Arguments == terminalSettings.Arguments && t.Command == terminalSettings.Command)), Times.Once); }
public void SetTerminalSettings(TerminalSettingsStateModel terminalSettingsState) { using var uow = _unitOfWorkFactory.Create(); var repository = uow.GetRepository <TerminalSettings>(); var dbModel = CreateFrom(terminalSettingsState); repository.Upsert(TerminalSettingsId, dbModel); }
public void SaveChanges() { var settings = new TerminalSettingsStateModel { Command = TerminalCommandText, Arguments = TerminalCommandArguments }; _terminalService.SetTerminalSettings(settings); }
private static TerminalSettings CreateFrom(TerminalSettingsStateModel stateModel) => new TerminalSettings { Arguments = stateModel.Arguments, Command = stateModel.Command };
private static TerminalSettings CreateFrom(TerminalSettingsStateModel stateModel) =>