public void CreateDisplayStrategy() { _view = Substitute.For<ITestTreeView>(); _model = Substitute.For<ITestModel>(); _strategy = GetDisplayStrategy(); }
public void CreateDisplayStrategy() { _view = Substitute.For <ITestTreeView>(); _model = Substitute.For <ITestModel>(); _strategy = GetDisplayStrategy(); }
public void CreateDisplayStrategy() { _view = Substitute.For <ITestTreeView>(); _model = Substitute.For <ITestModel>(); _settings = new TestCentric.TestUtilities.Fakes.UserSettings(); _model.Settings.Returns(_settings); _strategy = GetDisplayStrategy(); }
public string DisplayUsingStrategy(DisplayStrategy displayStrategy) { if (displayStrategy == DisplayStrategy.LastFirst) return string.Format("{0}, {1}", LastName, FirstName); else if (displayStrategy == DisplayStrategy.FirstLast) return string.Format("{0} {1}", FirstName, LastName); else if (displayStrategy == DisplayStrategy.Email) return Email; else return string.Empty; }
public void Display_PrintsException_GivenExceptionIsPassed() { using (StringWriter sw = new StringWriter()) { Console.SetOut(sw); DisplayStrategy displayStrategy = new DisplayStrategy(); displayStrategy.Display(new Exception()); string expected = string.Format("ERROR: Exception of type 'System.Exception' was thrown.", Environment.NewLine); Assert.AreEqual <string>(expected, sw.ToString()); } }
public void Display_PrintsResult_GivenNumberIsPassed() { using (StringWriter sw = new StringWriter()) { Console.SetOut(sw); DisplayStrategy displayStrategy = new DisplayStrategy(); int answer = 5; displayStrategy.Display(answer); string expected = string.Format("The difference is 5", Environment.NewLine); Assert.AreEqual <string>(expected, sw.ToString()); } }
public void CreateDisplayStrategy() { _view = Substitute.For <ITestTreeView>(); _model = Substitute.For <ITestModel>(); _settings = new TestCentric.TestUtilities.Fakes.UserSettings(); _settings.Gui.TestTree.SaveVisualState = false; _model.Settings.Returns(_settings); // We can't construct a TreeNodeCollection, so we fake it var nodes = new TreeNode().Nodes; nodes.Add(new TreeNode("test.dll")); _view.Tree.Nodes.Returns(nodes); _strategy = GetDisplayStrategy(); }
public FileContentResult TagCloud() { const int Width = 214; const int Height = 500; var weightedTags = Tags.WeightedList(); FontFamily font; using (var service = new FontsService()) { service.LoadFonts(Request.MapPath(@"~\Content\Fonts")); font = service.AvailableFonts["Kenyan Coffee"]; } var tagCloudService = new TagCloudService(weightedTags, Width, Height) { MaximumFontSize = 52f, MinimumFontSize = 18f, Margin = 10, SelectedFont = font, DisplayChoice = DisplayStrategy.Get(TagDisplayStrategy.MoreHorizontalThanVertical), ColorChoice = ColorStrategy.Get( Theme.LightBgDarkFg, Style.RandomVaried, Color.FromArgb(0, Color.White), Color.Black), VerticalTextRight = true, Crop = true }; Dictionary <string, RectangleF> borders; var bitmap = tagCloudService.Construct(out borders); if (tagCloudService.WordsSkipped.Any()) { var msg = "Need a bigger Image - these words skipped : " + string.Join("; ", tagCloudService.WordsSkipped.Select(x => x.Key)); ErrorSignal.FromCurrentContext().Raise(new Exception(msg)); } TempData["TagCloudBorders"] = borders; var stream = new MemoryStream(); bitmap.Save(stream, ImageFormat.Png); return(File(stream.ToArray(), Constants.PngContentType)); }
public string DisplayUsingStrategy(DisplayStrategy displayStrategy) { if (displayStrategy == DisplayStrategy.LastFirst) { return(string.Format("{0}, {1}", LastName, FirstName)); } else if (displayStrategy == DisplayStrategy.FirstLast) { return(string.Format("{0} {1}", FirstName, LastName)); } else if (displayStrategy == DisplayStrategy.Email) { return(Email); } else { return(string.Empty); } }
public ActionResult Cloud(TinkerModel Model) { Model.Strategies.AddRange(Enum.GetNames(typeof(TagDisplayStrategy))); Model.Themes.AddRange(Enum.GetNames(typeof(Theme))); Model.Styles.AddRange(Enum.GetNames(typeof(Style))); Dictionary <string, int> tags; try { tags = Model.Dictionary(); } catch (Exception ex) { ErrorSignal.FromCurrentContext().Raise(ex); return(File("~/Content/Images/404.png", "image/png")); } var tagCloudService = new TagCloudService(tags, int.Parse(Model.Width), int.Parse(Model.Height)) { MaximumFontSize = float.Parse(Model.MaxFontSize), MinimumFontSize = float.Parse(Model.MinFontSize), }; if (!String.IsNullOrEmpty(Model.Angle)) { tagCloudService.Angle = int.Parse(Model.Angle); } if (!String.IsNullOrEmpty(Model.Margin)) { tagCloudService.Margin = int.Parse(Model.Margin); } using (var Service = new FontsService()) { Service.LoadFonts(Request.MapPath("~/Content/Fonts")); Model.Fonts.AddRange(Service.AvailableFonts.Keys.ToArray()); if (!String.IsNullOrEmpty(Model.SelectedFont)) { tagCloudService.SelectedFont = Service.AvailableFonts[Model.SelectedFont]; } } if (!String.IsNullOrEmpty(Model.SelectedStrategy)) { tagCloudService.DisplayChoice = DisplayStrategy.Get(Model.SelectedStrategy.Enumize <TagDisplayStrategy>()); } var BgfgScheme = !String.IsNullOrEmpty(Model.SelectedTheme) ? Model.SelectedTheme.Enumize <Theme>() : Theme.LightBgDarkFg; var FgScheme = !String.IsNullOrEmpty(Model.SelectedStyle) ? Model.SelectedStyle.Enumize <Style>() : Style.Varied; tagCloudService.ColorChoice = ColorStrategy.Get(BgfgScheme, FgScheme, Model.GetBackgroundColor(), Model.GetForegroundColor()); tagCloudService.VerticalTextRight = Model.VerticalTextRight; tagCloudService.ShowWordBoundaries = Model.ShowBoundaries; tagCloudService.Crop = Model.Crop; tagCloudService.SpiralRoom = Model.SpiralRoom; var watch = new Stopwatch(); watch.Start(); Dictionary <string, RectangleF> Borders; var Bitmap = tagCloudService.Construct(out Borders); watch.Stop(); TempData["TinkerBorders"] = Borders; TempData["GenerateTime"] = watch.ElapsedMilliseconds / (float)1000; TempData["Skipped"] = string.Join("; ", tagCloudService.WordsSkipped.Select(x => x.Key)); var stream = new MemoryStream(); Bitmap.Save(stream, ImageFormat.Png); return(File(stream.ToArray(), "image/png")); }