Guest User

Untitled

a guest
Apr 25th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.83 KB | None | 0 0
  1.  /// <summary>
  2.         ///A test for button_del_Click
  3.         ///</summary>
  4.         [TestMethod()]
  5.         [DeploymentItem("SDKSample.exe")]
  6.         public void button_del_ClickTest()
  7.         {
  8.             MockRepository mocks = new MockRepository();
  9.             IImageRepository imgRepos = mocks.StrictMock<IImageRepository>();
  10.  
  11.             using (mocks.Record())
  12.             {
  13.                 Expect
  14.                    .Call(imgRepos.GetFirstKey())
  15.                    .Return(1);
  16.                 Expect
  17.                     .Call(imgRepos.GetNextKey(1))
  18.                     .Return(2);
  19.                 Expect
  20.                     .Call(imgRepos.GetEntity(1))
  21.                     .Return(Image.FromFile("C:\\Users\\abuobe\\Desktop\\Photo_Flipper_Demo_Copy\\TestProject_GraphicalComponents\\images\\pic_011.png"));
  22.                 Expect
  23.                     .Call(imgRepos.GetEntity(2))
  24.                     .Return(Image.FromFile("C:\\Users\\abuobe\\Desktop\\Photo_Flipper_Demo_Copy\\TestProject_GraphicalComponents\\images\\pic_012.png"));
  25.  
  26.                 imgRepos.DelEntity(1);
  27.                     LastCall.IgnoreArguments();
  28.  
  29.                 Expect
  30.                     .Call(imgRepos.GetNextKey(1))
  31.                     .Return(2);
  32.                 Expect
  33.                     .Call(imgRepos.GetNextKey(2))
  34.                     .Return(3);
  35.                 Expect
  36.                    .Call(imgRepos.GetEntity(2))
  37.                    .Return(Image.FromFile("C:\\Users\\abuobe\\Desktop\\Photo_Flipper_Demo_Copy\\TestProject_GraphicalComponents\\images\\pic_014.png"));
  38.                 Expect
  39.                    .Call(imgRepos.GetEntity(3))
  40.                    .Return(Image.FromFile("C:\\Users\\abuobe\\Desktop\\Photo_Flipper_Demo_Copy\\TestProject_GraphicalComponents\\images\\pic_015.png"));
  41.             }
  42.  
  43.             IDisplayParametersRepository dispParamRepos = mocks.StrictMock<IDisplayParametersRepository>();
  44.  
  45.             using (mocks.Record())
  46.             {
  47.                 Expect
  48.                    .Call(dispParamRepos.GetUserKey())
  49.                    .Return(2);
  50.                 Expect
  51.                     .Call(dispParamRepos.GetEntity(2))
  52.                     .Return(new DisplayParameters(new System.Windows.Media.Media3D.Point3D(0.05, 0.05, 0.05), TimeSpan.FromMilliseconds(1000)));
  53.             }
  54.  
  55.             Window1_Accessor target = new Window1_Accessor(); // TODO: Initialize to an appropriate value
  56.             target._imgRepository = imgRepos;
  57.             target._dispParamRepository = dispParamRepos;
  58.             object sender = this; // TODO: Initialize to an appropriate value
  59.             EventArgs e = EventArgs.Empty; // TODO: Initialize to an appropriate value
  60.             target.OnLoaded(sender, e);
  61.             target.button_del_Click(null, null);
  62.             Assert.AreEqual(target._currentPic, 2);
  63.         }
Add Comment
Please, Sign In to add comment