public void DutyReportIsCorrectlyGeneratedAndReset() { mockReporter.Setup(f => f.GetPrefill()).Returns("test"); var now = DateTime.Now; ctrls.Start.Value = now; ctrls.End.Value = now.AddMinutes(90); ctrls.Arrests.Text = "2"; ctrls.Citations.Text = "4"; var ctrlr = new DutyReportController(ctrls, () => mockReporter.Object, typeof(FakeReporter)); ctrls.Notes.Text = "some notes"; btnGenDutyReport.SimulateMouseUp(MouseButtons.Left); Assert.AreEqual(1, FakeReporter.ctorCalls.Count); var args = FakeReporter.ctorCalls[0]; var i = 0; Assert.AreEqual(now, (DateTime)args[i++]); Assert.AreEqual(now.AddMinutes(90), (DateTime)args[i++]); Assert.AreEqual(2, (decimal)args[i++]); Assert.AreEqual(4, (decimal)args[i++]); Assert.AreEqual("some notes", args[i++] as string); btnGenDutyReport.SimulateMouseUp(MouseButtons.Right); Assert.AreEqual("test", ctrls.Notes.Text); mockReporter.Verify(f => f.GetPrefill()); }
public void ImpoundReleaseReporterCorrectlyGeneratesAndResetsReport() { _ = new ImpoundReleaseReportController(ctrls, mockSuspMgr.Object, typeof(FakeReporter)); ctrls.SuspName.Text = "SN"; ctrls.SuspPhone.Text = "6666666"; ctrls.LicensePlate.Text = "ASDF"; ctrls.VehicleModel.Text = "Bifta"; ctrls.VehicleColor.Text = "Red"; ctrls.ImpoundDate.Value = new DateTime(2010, 12, 23); ctrls.ImpOfficer.Text = "officer"; ctrls.ReleaseFee.Text = "123"; btnGenReport.SimulateMouseUp(MouseButtons.Left); Assert.AreEqual(1, FakeReporter.ctorCalls.Count); var i = 0; var args = FakeReporter.ctorCalls[0]; Assert.AreEqual("SN", args[i++] as string); Assert.AreEqual("6666666", args[i++] as string); Assert.AreEqual("ASDF", args[i++] as string); Assert.AreEqual("Bifta", args[i++] as string); Assert.AreEqual("Red", args[i++] as string); Assert.AreEqual(new DateTime(2010, 12, 23), (DateTime)args[i++]); Assert.AreEqual("officer", args[i++] as string); Assert.AreEqual("123", args[i++] as string); btnGenReport.SimulateMouseUp(MouseButtons.Right); Assert.AreEqual("", ctrls.SuspName.Text); Assert.AreEqual("", ctrls.SuspPhone.Text); Assert.AreEqual("", ctrls.LicensePlate.Text); Assert.AreEqual("", ctrls.ReleaseFee.Text); btnGenReport.SimulateMouseUp(MouseButtons.Left); Assert.AreEqual("0", FakeReporter.ctorCalls[1][7] as string); }
public void FirearmLicenseControllerCorrectlyGeneratesReport() { var formA = new HashSet <IRejection>(); var formB = new HashSet <IRejection>(); var tstRej = new Rejection("Code1", "Desc1", "Reason1", RejectionState.REAPPLY); formA.Add(tstRej); formA.Add(new Rejection("Code2", "Desc2", "Reason2", RejectionState.AMENDIT)); formB.Add(new Rejection("Code3", "Desc3", "Reason3", RejectionState.FOREVER)); formB.Add(new Rejection("Code4", "Desc4", "Reason4", RejectionState.TMPCRIM)); mockRejList.SetupGet(f => f.FormA).Returns(formA); mockRejList.SetupGet(f => f.FormB).Returns(formB); var ctrlr = new FirearmLicenseController(ctrls, typeof(FakeReporter), typeof(FakeReporter), mockRejList.Object); Assert.IsTrue(formA.SetEquals(ctrls.FormA.Items.Cast <IRejection>())); Assert.IsTrue(formB.SetEquals(ctrls.FormB.Items.Cast <IRejection>())); Assert.IsFalse(ctrls.GenReport.Enabled); ctrls.PrevDenial.Checked = true; Assert.IsTrue(ctrls.GenReport.Enabled); ctrls.LastOffence.Value = DateTime.UtcNow.AddMonths(-1); Assert.IsTrue(ctrls.ActiveOffence.Visible); ctrls.DateOfBirth.Value = DateTime.UtcNow.AddYears(-20); Assert.IsTrue(ctrls.Underage.Visible); ctrls.FormA.SetItemChecked(0, true); Assert.IsFalse(ctrls.FormB.Enabled); ctrls.FormB.SetItemChecked(0, true); Assert.IsFalse(ctrls.FormA.Enabled); Assert.IsTrue(ctrls.IsFormB.Checked); ctrls.FormB.SetItemChecked(0, false); ctrls.IsFormB.Checked = false; ctrls.FormA.Enabled = true; ctrls.Name.Text = "Joe Smith"; genReport.SimulateMouseUp(MouseButtons.Left); Assert.AreEqual(1, FakeReporter.ctorCalls.Count); var args = FakeReporter.ctorCalls[0]; Assert.AreEqual("Joe Smith", args[0] as string); Assert.IsFalse((bool)args[1]); Assert.AreEqual(ctrls.LastOffence.Value, (DateTime)args[2]); var rej = (args[3] as IEnumerable <object>).Cast <IRejection>(); Assert.AreEqual(1, rej.Count()); Assert.AreEqual(tstRej, rej.First()); }
public void ImpoundReportIsCorrectlyGeneratedAndReset() { mockReporter.Setup(f => f.GetPrefill()).Returns("prefill"); var ctrlr = new ImpoundReportController(ctrls, mockSuspMgr.Object, () => mockReporter.Object, typeof(FakeReporter)); mockReporter.VerifyAll(); var now = DateTime.Now; ctrls.SuspName.Text = "some crim"; ctrls.SuspPhone.Text = "3434343"; ctrls.LicensePlate.Text = "asdgf"; ctrls.VehicleModel.Text = "Bifta"; ctrls.VehicleColor.Text = "Blue"; ctrls.VehicleDetails.Text = "stuff"; ctrls.ImpoundTime.Value = now; ctrls.Location.Text = "loc"; ctrls.Reason.Text = "rsn"; ctrls.Officers.Text = "john smith"; ctrls.Screenshot.Text = "scrn"; btnGenReport.SimulateMouseUp(MouseButtons.Left); Assert.AreEqual(1, FakeReporter.ctorCalls.Count); var args = FakeReporter.ctorCalls[0]; var i = 0; Assert.AreEqual("Some Crim", args[i++] as string); Assert.AreEqual("3434343", args[i++] as string); Assert.AreEqual("ASDGF", args[i++] as string); Assert.AreEqual("Bifta", args[i++] as string); Assert.AreEqual("Blue", args[i++] as string); Assert.AreEqual("stuff", args[i++] as string); Assert.AreEqual(now, (DateTime)args[i++]); Assert.AreEqual("loc", args[i++] as string); Assert.AreEqual("rsn", args[i++] as string); Assert.AreEqual("John Smith", args[i++] as string); Assert.AreEqual("scrn", args[i++] as string); mockReporter.Setup(f => f.GetPrefill()).Returns("prefill"); btnGenReport.SimulateMouseUp(MouseButtons.Right); mockReporter.VerifyAll(); Assert.AreEqual("prefill", ctrls.Officers.Text); }
public void ControllerSuccessfullyGeneratesAnArrestReport() { string[] strs = new string[] { "", "", "", "" }; mockCrime1.SetupGet(f => f.Prefix).Returns(() => strs[0]); mockCrime1.SetupGet(f => f.Suffix).Returns(() => strs[1]); var ctrlr = new ArrestReportController(ctrls, mockSuspMgr.Object, () => mockReporter.Object, rptT, mockCrimeList.Object); chkCrimes.SetItemChecked(0, true); chkCrimes.SelectedIndex = 0; mockCrime1.Setup(f => f.AddSuffix(It.IsAny <string>())).Callback((string s) => strs[1] = s); mockCrime1.Setup(f => f.AddPrefix("Accessory to ")).Callback((string s) => strs[0] = s); for (var i = 0; i < 3; ++i) { btnAccessory.PerformClick(); btnGovEmployee.PerformClick(); } mockCrime1.VerifyAll(); chkCrimes.SelectedIndex = -1; btnAggravated.PerformClick(); suggestCharge.Text = "Test2"; mockCrime2.Setup(f => f.Equals(It.IsAny <string>())).Returns(true); suggestCharge.SimulateKeyUp(new KeyEventArgs(Keys.A)); Assert.AreEqual(-1, chkCrimes.SelectedIndex); suggestCharge.SimulateKeyUp(new KeyEventArgs(Keys.Enter)); mockCrime2.VerifyAll(); Assert.AreEqual(1, chkCrimes.SelectedIndex); Assert.IsTrue(chkCrimes.GetItemChecked(1)); officers.SetupProperty(f => f.Text, "john smith\nJane doe"); officers.Setup(f => f.Multiline).Returns(true); ctrls.SuspName.Text = "some crim"; ctrls.SuspPhone.Text = "1234567"; ctrls.LicensesRevoked.Checked = true; ctrls.Mugshot.Text = "abcdef"; ctrls.Narrative.Text = "Narrative"; btnGenArrestReport.SimulateMouseUp(MouseButtons.Left); officers.VerifyAll(); Assert.AreEqual("John Smith\nJane Doe", officers.Object.Text); Assert.AreEqual("Fake report", Clipboard.GetText()); Assert.AreEqual(1, FakeReporter.ctorCalls.Count); var args = FakeReporter.ctorCalls[0]; Assert.AreEqual(7, args.Length); var a = 0; Assert.AreEqual("Some Crim", args[a++] as string); Assert.AreEqual("1234567", args[a++] as string); Assert.IsTrue((bool)args[a++]); var offStrs = args[a++] as string[]; Assert.AreEqual(2, offStrs.Length); Assert.AreEqual("John Smith", offStrs[0]); Assert.AreEqual("Jane Doe", offStrs[1]); Assert.AreEqual("abcdef", args[a++] as string); var crimes = (args[a++] as IEnumerable <object>).GetEnumerator(); crimes.MoveNext(); Assert.AreEqual(chkCrimes.Items[0] as Crime, crimes.Current as Crime); crimes.MoveNext(); Assert.AreEqual(chkCrimes.Items[1] as Crime, crimes.Current as Crime); Assert.AreEqual("Narrative", args[a++] as string); }