public MainWindow() { InitializeComponent(); _loadedData = new RdbNets { fileName = "", Nets = new RdbNet[] {} }; LoadData(); bgw = new BackgroundWorker(); _updateRDB = new UpdateRDB(); }
public void WhenUpdate() { //Arrange _updateRdb = Mocker.CreateInstance <UpdateRDB>(); _testNets = AutoFixture.Create <TestNets>(); _pivot = AutoFixture.Create <Point>(); _angle = AutoFixture.Create <float>(); _backgroundworker = new BackgroundWorker(); _results = null; _canComplete = false; var expectedPoint = new Point { X = 1, Y = 1 }; Mocker.GetMock <IMovePoint>() .Setup(move => move.RotateAround(It.IsAny <Point>(), _pivot, _angle)) .Returns(expectedPoint); //Act _backgroundworker.DoWork += new DoWorkEventHandler(bgw_Test); _backgroundworker.ProgressChanged += new ProgressChangedEventHandler(bgw_ProgressChanged); _backgroundworker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgw_RunWorkerCompleted); _backgroundworker.WorkerReportsProgress = true; _backgroundworker.RunWorkerAsync(); while (_canComplete == false) { } var resultPoints = _results.Nets.SelectMany(pins => pins.pins.Select(pin => new Point { X = pin.x, Y = pin.y })) .ToArray(); //Assert var i = 0; while (i < resultPoints.Length) { resultPoints[i].X.Should().Be(expectedPoint.X); resultPoints[i].Y.Should().Be(expectedPoint.Y); i++; } _results.CentroidX.Should().Be((float)1); _results.CentroidY.Should().Be((float)1); _progress.Should().Be(100); }