Exemplo n.º 1
0
 public TargetingSystem(IVectorProvider vectorProvider, Satellite target, LaunchSite launcher, DateTime launchTime)
     : this(vectorProvider)
 {
     this.target = target;
     this.launcher = launcher;
     this.launchTime = launchTime;
 }
Exemplo n.º 2
0
 public void ComputeVelocity()
 {
     Satellite s = new Satellite();
     s.Altitude = 0;
     // solved this one on paper:
     Assert.That(s.OrbitalVelocity, Is.EqualTo(7.909963659).Within(0.0000000001));
 }
Exemplo n.º 3
0
 public void NegativeAltitudeNotAllowed()
 {
     Satellite s = new Satellite();
     try
     {
         s.Altitude = -1;
         Assert.Fail("Altitude can't be negative");
     } catch(ArgumentOutOfRangeException)
     {
         // success
     }
 }
Exemplo n.º 4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                Satellite sat = new Satellite();
                sat.Name = txtSatName.Text;
                sat.Altitude = double.Parse(txtAltitude.Text);
                sat.Save();

                txtSatName.Text = "";
                txtAltitude.Text = "";
            }
        }
Exemplo n.º 5
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;
        }
Exemplo n.º 6
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();
        }
Exemplo n.º 7
0
 public TargetingSystem(Satellite target, LaunchSite launcher, DateTime launchTime)
 {
     this.target = target;
     this.launcher = launcher;
     this.launchTime = launchTime;
 }
Exemplo n.º 8
0
 public void ComputeVelocity_ZeroAltitude()
 {
     Satellite s = new Satellite();
     s.Altitude = 0;
     Assert.That(s.OrbitalVelocity, Is.EqualTo(7.909).Within(0.001));
 }
Exemplo n.º 9
0
 public void ComputeVelocity_GeosynchronousOrbit()
 {
     Satellite s = new Satellite();
     s.Altitude = 35780; // numbers from wikipedia
     Assert.That(s.OrbitalVelocity, Is.EqualTo(3.07).Within(0.01));
 }