public void VerifyStepExecutedAndStepExecutingAreRaised() { IMigrationStep step = MockRepository.GenerateStub<IMigrationStep>(); var metadata = new Metadata1(); step.Expect(s => s.Metadata).Return(metadata); step.Expect(s => s.Report(null)).IgnoreArguments().Return(CreateMigrationReport()); IMigrationStep[] steps = new[] { step, }; IVersioning versioning = MockRepository.GenerateStub<IVersioning>(); var batch = new MigrationBatch(steps, Enumerable.Empty<IMigrationMetadata>(), versioning, new MigrationOptions()); Assert.AreSame(metadata, batch.ScheduledMigrations[0], "The batch should expose the metadata of the step."); // this is tested to allow for the undocumented feature test below int countExecutingEvent = 0; int countExecutedEvent = 0; batch.StepExecuting += (sender, args) => { // note: the following assertion tests an undocumented feature Assert.AreSame(metadata, args.Metadata, "The event should carry the same metadata that is in the ScheduleMigrations collection."); countExecutingEvent++; }; batch.StepExecuted += (sender, args) => { // note: the following assertion tests an undocumented feature Assert.AreSame(metadata, args.Metadata, "The event should carry the same metadata that is in the ScheduleMigrations collection."); countExecutedEvent++; }; batch.Execute(); Assert.IsTrue(batch.IsExecuted); Assert.AreEqual(steps.Length, countExecutingEvent); Assert.AreEqual(steps.Length, countExecutedEvent); }
public FlightSecuritySharepointData getSecurity(SecurityModel sd) { FlightSecuritySharepointData sddp = new FlightSecuritySharepointData(); sddp.MobileEntry = true; sddp.Type_x0020_of_x0020_Report = "Security Report"; sddp.Aircraft_x0020_Registration = sd.AircraftRegistration; sddp.Event_x0020_Title = sd.EventTitle; sddp.Details_x0020_of_x0020_Event_x0020__x0020_Hazard = sd.DescribeEvent != null ? "<div class=\"ExternalClass733EA004DCC641EFAFED516F5D12CCA7\"><br>\u200b" + sd.DescribeEvent + "<br><\u002fdiv>" : null; sddp.FlightNumber = sd.FlightNumber; sddp.Date_x0020_of_x0020_Event = sd.DateOfEvent.ToString("yyyy-MM-dd") + "T07:00:00Z"; sddp.Departure_x0020_Station = sd.DepartureStation; sddp.Arrival_x0020_Station = sd.ArrivalStation; sddp.Divert_x0020_Station = sd.DivertStation; sddp.Location_Station_Area_FIR_x0020_of_x0020_Event = sd.Area_FIR; sddp.Attachments = sd.Attachment; sddp.MOR_x0020_TypeId = SSIRShortForm.MORTypeID != null?Convert.ToString(SSIRShortForm.MORTypeID + 1) : null; sddp.CONFIDENTIAL_x0020_REPORT = sd.ConfiReport == true ? "1" : "0"; sddp.Send_x0020_Notifications = sd.ssQ == true ? "1" : "0"; sddp.Others_x0020_Persons_x0020_Invol = sd.pax; sddp.groudWhere = securityReportView.flightwheresel; sddp.FlightEvent = securityReportView.flightphase; List <string> strData = sd.securityEvent != null?sd.securityEvent.Trim(',').Split(',').ToList() : null; if (strData != null) { SecurityEventFieldChoice sfapp = new SecurityEventFieldChoice(); sfapp.results = strData; Metadata1 md1 = new Metadata1(); md1.type = "Collection(Edm.String)"; sfapp.__metadata = md1; sddp.securityEvent = sfapp; } if (!string.IsNullOrEmpty(sd.policereport)) { if (Uri.IsWellFormedUriString(sd.policereport, UriKind.Absolute)) { sddp.PoliceReport = new SPFieldURL { Url = sd.policereport }; } else { throw new Exception(string.Format("'{0}' is not a valid url", sd.policereport)); } } sddp.SubmitterEmail = sd.SubmitterEmail; sddp.NameStaffNumber = sd.NameStaffNumber; return(sddp); }
public void VerifyStepExecutedAndStepExecutingAreRaised() { IMigrationStep step = MockRepository.GenerateStub <IMigrationStep>(); var metadata = new Metadata1(); step.Expect(s => s.Metadata).Return(metadata); step.Expect(s => s.Report(null)).IgnoreArguments().Return(CreateMigrationReport()); IMigrationStep[] steps = new[] { step, }; IVersioning versioning = MockRepository.GenerateStub <IVersioning>(); var batch = new MigrationBatch(steps, Enumerable.Empty <IMigrationMetadata>(), versioning, new MigrationOptions()); Assert.AreSame(metadata, batch.ScheduledMigrations[0], "The batch should expose the metadata of the step."); // this is tested to allow for the undocumented feature test below int countExecutingEvent = 0; int countExecutedEvent = 0; batch.StepExecuting += (sender, args) => { // note: the following assertion tests an undocumented feature Assert.AreSame(metadata, args.Metadata, "The event should carry the same metadata that is in the ScheduleMigrations collection."); countExecutingEvent++; }; batch.StepExecuted += (sender, args) => { // note: the following assertion tests an undocumented feature Assert.AreSame(metadata, args.Metadata, "The event should carry the same metadata that is in the ScheduleMigrations collection."); countExecutedEvent++; }; batch.Execute(); Assert.IsTrue(batch.IsExecuted); Assert.AreEqual(steps.Length, countExecutingEvent); Assert.AreEqual(steps.Length, countExecutedEvent); }
public FlightSafetyReportModelSp getflightSafetyJson(FlightSafetyReportModel sd) { FlightSafetyReportModelSp sddp = new FlightSafetyReportModelSp(); sddp.MobileEntry = true; List <string> strData = sd.ApproachType != null?sd.ApproachType.Trim(',').Split(',').ToList() : null; List <string> relativeStr = sd.Relativeposition != null?sd.Relativeposition.Trim(',').Split(',').ToList() : null; List <string> deviation = sd.ReasonforDeviation != null?sd.ReasonforDeviation.Trim(',').Split(',').ToList() : null; if (strData != null) { ApproachType sfapp = new ApproachType(); sfapp.results = strData; Metadata1 md1 = new Metadata1(); md1.type = "Collection(Edm.String)"; sfapp.__metadata = md1; sddp.ApproachType = sfapp; } if (relativeStr != null) { ReasonForDeviation rsDev = new ReasonForDeviation(); rsDev.results = deviation; Metadata2 md2 = new Metadata2(); md2.type = "Collection(Edm.String)"; rsDev.__metadata = md2; sddp.ReasonforDeviation = rsDev; } if (deviation != null) { IntruderACRelativePosition intru = new IntruderACRelativePosition(); intru.results = deviation; Metadata3 md3 = new Metadata3(); md3.type = "Collection(Edm.String)"; intru.__metadata = md3; sddp.Relativeposition = intru; } sddp.ReportType = "Flight Safety Report";// sd.ReportType; sddp.AircraftRegis = sd.AircraftRegistration; sddp.EventTitle = sd.EventTitle; sddp.FlightNumber = sd.FlightNumber; sddp.DateOfEvent = sd.DateOfEvent.ToString("yyyy-MM-dd") + "T07:00:00Z"; sddp.DepartureStation = sd.DepartureStation; sddp.ArrivalStation = sd.ArrivalStation; sddp.DivertStation = sd.DivertStation; sddp.Area_FIR = sd.Area_FIR; sddp.DescribeEvent = sd.DescribeEvent != null ? "<div class=\"ExternalClass733EA004DCC641EFAFED516F5D12CCA7\"><br>\u200b" + sd.DescribeEvent + "<br><\u002fdiv>" : null; sddp.Attachment = sd.Attachment; sddp.MOR = SSIRShortForm.MORTypeID != null?Convert.ToString(SSIRShortForm.MORTypeID + 1) : null; //Convert.ToString(sd.MOR + 1); sddp.ConfiReport = sd.ConfiReport == true ? "1" : "0"; sddp.ssQ = sd.ssQ == true ? "1" : "0"; sddp.pax = sd.pax; sddp.CommanderPForPM = FlightSafetyReportView.CommanderPForPMpickerValue; if (FlightSafetyReportView.PeoplePickerCommander != null) { sddp.CommandersEmail = FlightSafetyReportView.PeoplePickerCommander.Id.ToString(); } if (FlightSafetyReportView.PeoplePickercrew1email != null) { sddp.FlightCrew1 = FlightSafetyReportView.PeoplePickercrew1email.Id.ToString(); } if (FlightSafetyReportView.PeoplePickercrew2email != null) { sddp.FlightCrew2 = FlightSafetyReportView.PeoplePickercrew2email.Id.ToString(); } sddp.FlightCrew1PFPMOBs = FlightSafetyReportView.FlightCrew1PFPMOBspickerValue; sddp.FlightCrew2PFPMOBs = FlightSafetyReportView.FlightCrew2PFPMOBspickerValue; sddp.Ifflighteventselectphase = FlightSafetyReportView.IfflighteventselectphasepickerValue; sddp.Ifongroundselectwhere = FlightSafetyReportView.IfongroundselectwherepickerValue; sddp.Altitude = sd.Altitude; sddp.IASMach = sd.IASMach; sddp.AutopilotOn = sd.AutopilotOn == true ? "1" : "0"; sddp.ATOn = sd.ATOn == true ? "1" : "0"; // sddp.ApproachType = "{\"__metadata\":{\"type\":\"Collection(Edm.String)\"},\"results\":\"" + apptypestr + "\"}"; sddp.Heading = sd.Heading; sddp.VS = sd.VS; sddp.Gear = FlightSafetyReportView.GearpickerValue; sddp.Speedbrake = FlightSafetyReportView.SpeedbrakepickerValue; sddp.FlapPosition = sd.FlapPosition; sddp.Weight = sd.Weight; sddp.FuelDumping = sd.FuelDumping == true ? "1" : "0"; sddp.SeatbeltSign = sd.SeatbeltSign == true ? "1" : "0"; sddp.MeteorologicalReport = FlightSafetyReportView.MeteorologicalReportpickerValue; sddp.Wind = sd.Wind; sddp.VisRVR = sd.VisRVR; sddp.Temp = sd.Temp; sddp.Light = FlightSafetyReportView.LightpickerValue; sddp.Weather = FlightSafetyReportView.WeatherpickerValue; sddp.Precipitation = FlightSafetyReportView.PrecipitationpickerValue; sddp.Turbulence = FlightSafetyReportView.TurbulencepickerValue; sddp.RWYDirection = sd.RWYDirection; sddp.Conditions = FlightSafetyReportView.ConditionspickerValue; sddp.NAVAIDS = FlightSafetyReportView.NAVAIDSpickerValue; sddp.ClearedAltitude = sd.ClearedAltitude; sddp.DeviationHorizontal = sd.DeviationHorizontal; sddp.Vertical = sd.Vertical; // sddp.ReasonforDeviation = sd.ReasonforDeviation != null ? "<div class=\"ExternalClass733EA004DCC641EFAFED516F5D12CCA7\"><br>\u200b" + sd.ReasonforDeviation + "<br><\u002fdiv>" : null; sddp.TAAlert = sd.TAAlert == true ? "1" : "0"; sddp.RAAlert = sd.RAAlert == true ? "1" : "0"; sddp.RACommand = sd.RACommand; sddp.IntruderACType = sd.IntruderACType; sddp.Callsign = sd.Callsign; // sddp.Relativeposition = sd.Relativeposition != null ? "<div class=\"ExternalClass733EA004DCC641EFAFED516F5D12CCA7\"><br>\u200b" + sd.Relativeposition + "<br><\u002fdiv>" : null; sddp.Bearing = sd.Bearing; sddp.Range = sd.Range; sddp.ATC = FlightSafetyReportView.ATCorAirportReportFiledpickerValue; sddp.ATCUnit = sd.ATCUnit; sddp.Frequency = sd.Frequency; sddp.TypeofWarnings = sd.TypeofWarnings != null ? "<div class=\"ExternalClass733EA004DCC641EFAFED516F5D12CCA7\"><br>\u200b" + sd.TypeofWarnings + "<br><\u002fdiv>" : null; sddp.WildlifeType = sd.WildlifeType; sddp.Numberofbirds = FlightSafetyReportView.NumberofbirdspickerValue; sddp.SizeofWildlife = FlightSafetyReportView.SizeofWildlifepickerValue; sddp.AircraftDamage = FlightSafetyReportView.AircraftDamagepickerValue; sddp.ImpactAreaDamage = sd.ImpactAreaDamage != null ? "<div class=\"ExternalClass733EA004DCC641EFAFED516F5D12CCA7\"><br>\u200b" + sd.ImpactAreaDamage + "<br><\u002fdiv>" : null; sddp.SubmitterEmail = sd.SubmitterEmail; sddp.NameStaffNumber = sd.NameStaffNumber; return(sddp); }