示例#1
0
        public Vehicle CreateObject()
        {
            var vehicle    = new Vehicle("Test Vehicle");
            var repository = new VehicleRepository();
            var stream     = File.Open($"{RepoTestAid.VehiclePathDefault()}", FileMode.Create);

            #region Info Assignment

            #region Stages

            var stageOne = new Stage()
            {
                DryMass         = 250,
                WetMass         = 650,
                SpecificImpulse = 302
            };

            var stageTwo = new Stage()
            {
                DryMass         = 500,
                WetMass         = 1200,
                SpecificImpulse = 332
            };

            var stageThree = new Stage()
            {
                DryMass         = 2200,
                WetMass         = 7000,
                SpecificImpulse = 348
            };

            #endregion

            var note = new VehicleNote
            {
                Title   = "This is a Note.",
                Content = "This is a simple note, but it's my note."
            };

            vehicle.DryMass     = 30000;
            vehicle.WetMass     = 200000;
            vehicle.Price       = 130500;
            vehicle.VehicleType = VehicleType.LaunchVehicle;
            vehicle.StageInfo.Add(1, stageOne);
            vehicle.StageInfo.Add(2, stageTwo);
            vehicle.StageInfo.Add(3, stageThree);
            vehicle.VehicleNotes.Add(note);
            vehicle.CalculateDeltaV();
            #endregion

            using (stream)
            {
                repository.Serialize(stream, vehicle);
            }

            return(vehicle);
        }
        public void VehicleNoteTitleValid()
        {
            //Arrange
            var vehicleNote = new VehicleNote("Best Note");

            var expected = "Best Note";

            //Act
            var actual = vehicleNote.Title;

            //Assert
            Assert.AreEqual(expected, actual);
        }
        public void VehicleNoteContentSet()
        {
            //Arrange
            var vehicleNote = new VehicleNote();

            vehicleNote.Content = "This is a note. Maybe note a great one, but it's mine.";

            var expected = "This is a note. Maybe note a great one, but it's mine.";

            //Act
            var actual = vehicleNote.Content;

            //Assert
            Assert.AreEqual(expected, actual);
        }
        public void VehicleNoteTitleNotNull()
        {
            //Arrange
            var vehicleNote = new VehicleNote();

            var expected = "Invalid Title";

            //Act
            var actual = vehicleNote.Title;

            Console.WriteLine(vehicleNote.ToString());

            //Assert
            Assert.AreEqual(expected, actual);
        }
        public void VehicleNotesAdded()
        {
            //Arrange
            var vehicle = new Vehicle();
            var note    = new VehicleNote("Just To Say Hi");

            note.Content = "These Unit Tests Are Very Dull";

            vehicle.VehicleNotes.Add(note);

            var expected = new List <string> {
                "Just To Say Hi", "These Unit Tests Are Very Dull"
            };

            //Act
            var actual = new List <string> {
                vehicle.VehicleNotes[0].Title, vehicle.VehicleNotes[0].Content
            };

            //Assert
            CollectionAssert.AreEqual(expected, actual);
        }