/// <summary>
        /// Initializes a new instance of the <see cref="FiringSolution"/> class.
        /// set Vector to be the initialVector.
        /// </summary>
        /// <param name="system">The system.</param>
        /// <param name="initialVector">The initial vector.</param>
        public FiringSolution(TargetingSystem system, double initialVector)
        {
            #region TEST: check arguments
            // TEST: check arguments
            //            if (initialVector == 0.0)
            //                throw new ArgumentOutOfRangeException("initialVector", initialVector, "initial vector cannot be zero");
            //            if (system == null)
            //                throw new ArgumentNullException("system");
            #endregion

            this.system = system;
            storedVector = initialVector;
        }
Exemple #2
0
        protected void rptLaunchers_ItemCommand(object sender, RepeaterCommandEventArgs e)
        {
            int launcherId = int.Parse((string)e.CommandArgument);
            LaunchSite launcher = LaunchSite.Get(launcherId);
            Satellite sat = Satellite.Get(SatelliteId);

            // TEST: we want to be able to play with this code, without actually launching anything.
            // create a targeting system to hit this:
            TargetingSystem system = new TargetingSystem(sat, launcher, DateTime.Now);
            FiringSolution solution = system.ComputeFiringSolution();
            lblLaunchNotification.Visible = true;
            string result = solution.Fire();
            lblLaunchNotification.Text = "Missile Launched! " + result;
        }
Exemple #3
0
 protected void rptLaunchers_ItemCommand(object sender, RepeaterCommandEventArgs e)
 {
     int launcherId = int.Parse((string)e.CommandArgument);
     LaunchSite launcher = LaunchSite.Get(launcherId);
     Satellite sat = Satellite.Get(SatelliteId);
     // create a targeting system to hit this:
     TargetingSystem system = new TargetingSystem(sat, launcher, DateTime.Now);
     FiringSolution solution = system.ComputeFiringSolution();
     lblLaunchNotification.Visible = true;
     if (solution.Fire())
     {
         lblLaunchNotification.Text = "Missile Launched!";
     }
     else
     {
         lblLaunchNotification.Text = "Launch Failed!";
     }
 }
        public void ComputeFiringSolution()
        {
            MockRepository mocks = new MockRepository();
            IVectorProvider vectorProvider = mocks.CreateMock<IVectorProvider>();

            using (mocks.Record())
            {
                List<double> resultToReturn = new List<double>();
                resultToReturn.Add(1.0);
                Expect.Call(vectorProvider.GetTargetingVectors()).Return(resultToReturn);
            }

            using (mocks.Playback())
            {
                TargetingSystem system = new TargetingSystem(vectorProvider);
                FiringSolution solution = system.ComputeFiringSolution();

                // how do you test this when it comes from the disk, and theres no telling how long it could run?
                Assert.That(solution.Vector, Is.EqualTo(0.0));
            }
        }
        public void ComputeFiringSolution()
        {
            MockRepository mocks = new MockRepository();
            IVectorProvider vectorProvider = mocks.CreateMock<IVectorProvider>();
            Factory<IVectorProvider>.RegisterFake(vectorProvider);
            using (mocks.Record())
            {
                Expect.Call(vectorProvider.GetTargetingVectors()).Return(new List<double> { 1 });
            }
            using (mocks.Playback())
            {
                Satellite target = new Satellite();
                LaunchSite launcher = new LaunchSite();
                TargetingSystem system = new TargetingSystem(target, launcher, DateTime.Now);
                FiringSolution solution = system.ComputeFiringSolution();

                // how do you test this when it comes from the disk, and theres no telling how long it could run?
                Assert.That(solution.Vector, Is.EqualTo(0.0));
            }
            Factory<IVectorProvider>.ClearFakes();
        }
Exemple #6
0
        public static Collection<LaunchSite> LaunchersInRange(Satellite sat)
        {
            // to determine what's in range (and what isn't) first we need a set of launchers,
            // then (because this information is very sensitive) we're going to use some other
            // dependencies to figure out what can hit this satellite.
            string sql = Select;
            Collection<LaunchSite> result = new Collection<LaunchSite>();
            foreach(LaunchSite site in DataReaderContainer.ExecuteCollection<LaunchSite>(sql, new MissileConnectionFactory()))
            {
                // TODO: perhaps there is some processing we can do up front to determine if the site is in range or not
                // (obvious things to check: altitude)

                // targeting system needs to know: who, what, when.  it'll figure out how.
                TargetingSystem system = new TargetingSystem(sat, site, DateTime.Now);
                if (system.IsInRange)
                {
                    result.Add(site);
                }
            }
            return result;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="FiringSolution"/> class.
 /// Initializes vectors to start position.
 /// </summary>
 /// <param name="system">The system.</param>
 public FiringSolution(TargetingSystem system)
     : this(system, 1)
 {
 }
 public FiringSolution(TargetingSystem system)
 {
     this.system = system;
 }