void Run() { var exporter = new CustomSqlExporter(); exporter.InitializeContext(); var context = exporter.Context; Process = context.ProcessInfo; exporter.Context.FileSystem.CheckinComment = App.Model.CheckinComment; exporter.Context.FileSystem.IntegrateWithTFSAndCheckInAutomatically = App.Config.IntegrateWithTFSAndCheckInAutomatically; try { exporter.Export(ProfileName); } catch (Exception e) { context.Errors.Add(e.ToString()); } if (context.Errors.Any()) { context.ProcessInfo.Text = string.Join(Environment.NewLine, context.Errors); Thread.Sleep(TimeSpan.FromSeconds(2)); refresher.Stop(); return; } OnProcessCompletedSuccessfully(); }
static File Generate(List <ObjectParameterInfo> inputParameters, List <CustomSqlInfoResult> resultColumns) { File file = null; var currentDomain = AppDomain.CurrentDomain; Smock.Run(context => { var exporter = new CustomSqlExporter(); exporter.InitializeContext(); var map = new Dictionary <string, string>(); context.Setup(() => exporter.Context.FileSystem.WriteAllText(It.IsAny <string>(), It.IsAny <string>())).Callback((string path, string content) => { map.Add(path, content); }); var customSqlInfo = new CustomSqlInfo { Name = "Abc" }; context.Setup(() => It.IsAny <DatabaseReader>().GetCustomSqlNamesInfProfile()).Returns(new List <string> { string.Empty }); context.Setup(() => It.IsAny <DatabaseReader>().ReadCustomSqlInfo()).Returns(customSqlInfo); context.Setup(() => It.IsAny <DatabaseReader>().ReadInputParametersFromDatabase()).Returns(inputParameters); context.Setup(() => It.IsAny <DatabaseReader>().ReadResultColumns()).Returns(resultColumns); exporter.Export("Xyz"); file = new File { TypeCodes = map[map.Keys.ToList()[0]], SharedCodes = map[map.Keys.ToList()[1]] }; currentDomain.SetData(nameof(file), file); }); return((File)currentDomain.GetData(nameof(file))); }