public void CmdAdd_add_null() { StarFactory Starfactory = new StarFactory() { ResourceNamePattern = "AppLayerTesting.Graphics.{0}.png", ReferenceType = typeof(CmdAddTester) }; Drawing drawing = new Drawing(); CommandFactory commandFactory = new CommandFactory() { TargetDrawing = drawing }; drawing.Add(Starfactory.GetStar(new StarExtrinsicState() { StarType = "Star-01", Location = new Point(10, 10), Size = new Size(80, 80) })); Assert.Equal(1, drawing.StarCount); // creates star obj and stores in variable Star tempStar = Starfactory.GetStar(new StarExtrinsicState() { StarType = "Star-01", Location = new Point(10, 10), Size = new Size(80, 80) }); // creates command to add the star Command addCmd = commandFactory.Create("ADD"); Assert.Equal(null, addCmd); }
protected void testSetup(bool isMultiStars) { drawing = new Drawing() { IsDirty = false, Factory = starFactory }; star = starFactory.GetStar(new StarExtrinsicState() { StarType = "Star-01", Location = new Point(10, 10), Size = new Size(80, 80) }); drawing.Add(star); if (isMultiStars) { star = starFactory.GetStar(new StarExtrinsicState() { StarType = "Star-01", Location = new Point(20, 20), Size = new Size(20, 20) }); drawing.Add(star); star = starFactory.GetStar(new StarExtrinsicState() { StarType = "Star-01", Location = new Point(30, 30), Size = new Size(40, 40) }); drawing.Add(star); } drawing.IsDirty = false; }
public void CmdAdd_undo() { StarFactory Starfactory = new StarFactory() { ResourceNamePattern = "AppLayerTesting.Graphics.{0}.png", ReferenceType = typeof(CmdAddTester) }; Drawing drawing = new Drawing(); CommandFactory commandFactory = new CommandFactory() { TargetDrawing = drawing }; drawing.Add(Starfactory.GetStar(new StarExtrinsicState() { StarType = "Star-01", Location = new Point(10, 10), Size = new Size(80, 80) })); Assert.Equal(1, drawing.StarCount); Command addCmd = commandFactory.Create("ADD", "Star-01", new Point(10, 10), 1.0); addCmd.Execute(); addCmd.Undo(); Assert.Equal(1, drawing.StarCount); }
public void CmdScale_undo() { StarFactory Starfactory = new StarFactory() { ResourceNamePattern = "AppLayerTesting.Graphics.{0}.png", ReferenceType = typeof(CmdScaleTester) }; Drawing drawing = new Drawing(); CommandFactory commandFactory = new CommandFactory() { TargetDrawing = drawing }; drawing.Add(Starfactory.GetStar(new StarExtrinsicState() { StarType = "Star-01", Location = new Point(10, 10), Size = new Size(80, 80) })); Assert.Equal(1, drawing.StarCount); // creates star obj and stores in variable Command scaleCmd = commandFactory.Create("SCALE", 2.00); // creates command to add the star scaleCmd.Execute(); scaleCmd.Undo(); Star star = commandFactory.TargetDrawing.FindStarAtPosition(new Point(10, 10)); Assert.Equal(80, star.Size.Height); Assert.Equal(80, star.Size.Width); }
public void CmdSelected() { StarFactory Starfactory = new StarFactory() { ResourceNamePattern = "AppLayerTesting.Graphics.{0}.png", ReferenceType = typeof(CmdSelectedTester) }; Drawing drawing = new Drawing(); CommandFactory commandFactory = new CommandFactory() { TargetDrawing = drawing }; drawing.Add(Starfactory.GetStar(new StarExtrinsicState() { StarType = "Star-01", Location = new Point(10, 10), Size = new Size(80, 80) })); Assert.Equal(1, drawing.StarCount); Command selectedCmd = commandFactory.Create("SELECT", "Star-01", new Point(10, 10)); Assert.NotNull(selectedCmd); selectedCmd.Execute(); Star star = commandFactory.TargetDrawing.FindStarAtPosition(new Point(10, 10)); Assert.Equal(true, star.IsSelected); }
public static void Main(string[] args) { Console.WriteLine("Hello World!"); Invoker invoker = new Invoker(); invoker.Start(); StarFactory Starfactory = new StarFactory() { ResourceNamePattern = "AppLayerTesting.Graphics.{0}.png", ReferenceType = typeof(CmdNewTester) }; Drawing drawing = new Drawing(); CommandFactory commandFactory = new CommandFactory() { TargetDrawing = drawing }; drawing.Add(Starfactory.GetStar(new StarExtrinsicState() { StarType = "Star-01", Location = new Point(10, 10), Size = new Size(80, 80) })); drawing.Add(Starfactory.GetStar(new StarExtrinsicState() { StarType = "Star-01", Location = new Point(200, 310), Size = new Size(80, 80) })); drawing.Add(Starfactory.GetStar(new StarExtrinsicState() { StarType = "Star-01", Location = new Point(240, 150), Size = new Size(80, 80) })); drawing.Add(Starfactory.GetStar(new StarExtrinsicState() { StarType = "Star-01", Location = new Point(350, 300), Size = new Size(80, 80) })); Command newCmd = commandFactory.Create("NEW"); invoker.EnqueueCmd(newCmd) string type = "Star-01"; Point point = new Point(10, 10); Size size = new Size(80, 80); // creates command to add the star Command addCmd = commandFactory.Create("ADD", type, point, size); invoker.EnqueueCmd(addCmd) }
static void Main(string[] args) { StarFactory factory = new StarFactory(); for (int i = 0; i < 20; i++) { IStar red = factory.GetStar("Red"); Console.WriteLine("Red star created"); IStar green = factory.GetStar("Green"); Console.WriteLine("Green star created"); } Console.WriteLine("RedStar objects created: {0}", RedStar.objectCount); Console.WriteLine("GreenStar objects created: {0}", GreenStar.objectCount); Console.ReadLine(); }
public void CmdDeselectAll_DESELECT() { List <Star> starList = new List <Star>(); StarFactory Starfactory = new StarFactory() { ResourceNamePattern = "AppLayerTesting.Graphics.{0}.png", ReferenceType = typeof(CmdDeselectAll) }; Drawing drawing = new Drawing(); CommandFactory commandFactory = new CommandFactory() { TargetDrawing = drawing }; drawing.Add(Starfactory.GetStar(new StarExtrinsicState() { StarType = "Star-01", Location = new Point(10, 10), Size = new Size(80, 80), IsSelected = true })); drawing.Add(Starfactory.GetStar(new StarExtrinsicState() { StarType = "Star-01", Location = new Point(200, 310), Size = new Size(80, 80), IsSelected = true })); drawing.Add(Starfactory.GetStar(new StarExtrinsicState() { StarType = "Star-01", Location = new Point(240, 150), Size = new Size(80, 80), IsSelected = true })); drawing.Add(Starfactory.GetStar(new StarExtrinsicState() { StarType = "Star-01", Location = new Point(350, 300), Size = new Size(80, 80), IsSelected = true })); Assert.Equal(4, drawing.StarCount); Command deselectAllCmd = commandFactory.Create("DESELECT"); Assert.NotNull(deselectAllCmd); // Stimulate (Execute newCmd.Execute) deselectAllCmd.Execute(); // Assert the predicated results starList = drawing.GetSelected(); Assert.Equal(0, starList.Count); }
public void CmdNew_NonEmptyDrawing() { // Setup a drawing StarFactory Starfactory = new StarFactory() { ResourceNamePattern = "AppLayerTesting.Graphics.{0}.png", ReferenceType = typeof(CmdNewTester) }; Drawing drawing = new Drawing(); CommandFactory commandFactory = new CommandFactory() { TargetDrawing = drawing }; drawing.Add(Starfactory.GetStar(new StarExtrinsicState() { StarType = "Star-01", Location = new Point(10, 10), Size = new Size(80, 80) })); drawing.Add(Starfactory.GetStar(new StarExtrinsicState() { StarType = "Star-01", Location = new Point(200, 310), Size = new Size(80, 80) })); drawing.Add(Starfactory.GetStar(new StarExtrinsicState() { StarType = "Star-01", Location = new Point(240, 150), Size = new Size(80, 80) })); drawing.Add(Starfactory.GetStar(new StarExtrinsicState() { StarType = "Star-01", Location = new Point(350, 300), Size = new Size(80, 80) })); Assert.Equal(4, drawing.StarCount); // setup a New command Command newCmd = commandFactory.Create("NEW"); Assert.NotNull(newCmd); // Stimulate (Execute newCmd.Execute) newCmd.Execute(); // Assert the predicated results Assert.Equal(0, drawing.StarCount); }
public void CmdRemoveSelected_UNDO() { List <Star> starList = new List <Star>(); StarFactory Starfactory = new StarFactory() { ResourceNamePattern = "AppLayerTesting.Graphics.{0}.png", ReferenceType = typeof(CmdRemoveSelectedTester) }; Drawing drawing = new Drawing(); CommandFactory commandFactory = new CommandFactory() { TargetDrawing = drawing }; drawing.Add(Starfactory.GetStar(new StarExtrinsicState() { StarType = "Star-01", Location = new Point(10, 10), Size = new Size(80, 80) })); drawing.Add(Starfactory.GetStar(new StarExtrinsicState() { StarType = "Star-01", Location = new Point(200, 310), Size = new Size(80, 80) })); drawing.Add(Starfactory.GetStar(new StarExtrinsicState() { StarType = "Star-01", Location = new Point(240, 150), Size = new Size(80, 80) })); drawing.Add(Starfactory.GetStar(new StarExtrinsicState() { StarType = "Star-01", Location = new Point(350, 300), Size = new Size(80, 80) })); Assert.Equal(4, drawing.StarCount); Command removeSelectedCmd = commandFactory.Create("REMOVE"); Assert.NotNull(removeSelectedCmd); removeSelectedCmd.Execute(); removeSelectedCmd.Undo(); starList = drawing.GetObjects(); Assert.Equal(4, starList.Count); }
public void CmdScale_null() { StarFactory Starfactory = new StarFactory() { ResourceNamePattern = "AppLayerTesting.Graphics.{0}.png", ReferenceType = typeof(CmdScaleTester) }; Drawing drawing = new Drawing(); CommandFactory commandFactory = new CommandFactory() { TargetDrawing = drawing }; drawing.Add(Starfactory.GetStar(new StarExtrinsicState() { StarType = "Star-01", Location = new Point(10, 10), Size = new Size(80, 80) })); Assert.Equal(1, drawing.StarCount); Command scaleCmd = commandFactory.Create("SCALE"); Assert.Equal(null, scaleCmd); }