public ActionResult Create(Guitar guitar)
        {
            _context.Guitars.Add(guitar);
            _context.SaveChanges();

            return(RedirectToAction("Index"));
        }
示例#2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Brand,ModelName,NumOfStrings,Price")] Guitar guitar)
        {
            if (id != guitar.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(guitar);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GuitarExists(guitar.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(guitar));
        }
示例#3
0
文件: Tests.cs 项目: SchineD/oom
 public void CannotCreateGuitarWithoutStatingModel2()
 {
     Assert.Catch(() =>
     {
         var x = new Guitar("Ibanez", null, 2000m);
     });
 }
示例#4
0
        public async Task <IActionResult> Edit(Guitar guitar)
        {
            db.Guitars.Update(guitar);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        public ViewResult Edit(int Id)
        {
            Guitar guitar = repository.Guitars
                            .FirstOrDefault(p => p.Id == Id);

            return(View(guitar));
        }
示例#6
0
        public void OneSuccesfulSetAndOneFailed()
        {
            string expected = "1. mediumSet:" + Environment.NewLine + "-- 1. Song1 (05:00)" + Environment.NewLine + "-- Set Successful" + Environment.NewLine +
                              "2. shortSet:" + Environment.NewLine + "-- Did not perform";

            IStage stage = new Stage();

            string firstSetName = "shortSet";
            ISet   set1         = new Short(firstSetName);

            stage.AddSet(set1);

            string songName = "Song1";
            var    duration = new TimeSpan(0, 5, 0);
            ISong  song     = new Song(songName, duration);

            string performerName = "Pesho";
            int    age           = 20;
            var    performer     = new Performer(performerName, age);
            var    guitar        = new Guitar();

            performer.AddInstrument(guitar);

            string secondSetName = "mediumSet";
            ISet   set2          = new Medium(secondSetName);

            set2.AddPerformer(performer);
            set2.AddSong(song);
            stage.AddSet(set2);

            var    setController = new SetController(stage);
            string result        = setController.PerformSets();

            Assert.That(result, Is.EqualTo(expected));
        }
示例#7
0
        public void SetWithSongAndPerformer()
        {
            string expected = "1. mediumSet:" + Environment.NewLine + "-- 1. Song1 (05:00)" + Environment.NewLine + "-- Set Successful";

            string songName = "Song1";
            var    duration = new TimeSpan(0, 5, 0);
            ISong  song     = new Song(songName, duration);

            string performerName = "Pesho";
            int    age           = 20;
            var    performer     = new Performer(performerName, age);
            var    guitar        = new Guitar();

            performer.AddInstrument(guitar);

            IStage stage = new Stage();

            string setName = "mediumSet";
            ISet   set     = new Medium(setName);

            set.AddPerformer(performer);
            set.AddSong(song);
            stage.AddSet(set);

            var    setController = new SetController(stage);
            string result        = setController.PerformSets();

            Assert.That(result, Is.EqualTo(expected));
        }
示例#8
0
        public void PerformSetShouldDecreaseInstrumentWear()
        {
            IStage         stage         = new Stage();
            ISetController setController = new SetController(stage);


            ISet        set        = new Short("Set1");
            IPerformer  performer  = new Performer("Pesho", 18);
            IInstrument instrument = new Guitar();

            performer.AddInstrument(instrument);
            set.AddPerformer(performer);

            ISong song = new Song("Zaz - Ututudu", new TimeSpan(0, 2, 32));

            set.AddSong(song);

            stage.AddSet(set);

            double instrumentWearBeforePerforming = instrument.Wear;

            setController.PerformSets();

            double instrumentWearAfterPerforming = instrument.Wear;

            Assert.That(instrumentWearAfterPerforming, Is.Not.EqualTo(instrumentWearBeforePerforming));
        }
示例#9
0
        public void Test2()
        {
            var stage = new Stage();

            stage.AddSet(new Medium(nameof(Medium)));

            var songName  = "song1";
            var mediumSet = nameof(Medium);

            var performer = new Performer("performer", 22);
            var guitar    = new Guitar();

            performer.AddInstrument(guitar);

            var song = new Song(songName, new System.TimeSpan(0, 2, 22));

            stage.AddSong(song);
            var set = stage.GetSet(mediumSet);

            set.AddSong(song);
            set.AddSong(song);
            set.AddSong(song);
            set.AddSong(song);
            set.AddSong(song);
            set.AddPerformer(performer);



            var setController = new SetController(stage);
            var result        = setController.PerformSets().Split(System.Environment.NewLine);
        }
示例#10
0
        public void TestGetGuitarMetodNotFound()
        {
            Inventory inv         = new Inventory();
            Guitar    chitaraTest = inv.GetGuitar("NuExista");

            Assert.IsNull(chitaraTest);
        }
示例#11
0
文件: Tests.cs 项目: SchineD/oom
 public void CannotCreateGuitartWithNegativePrice()
 {
     Assert.Catch(() =>
     {
         var x = new Guitar("Epiphone", "blala", -80m);
     });
 }
        private static GetGuitarResponse HydrateGetGuitarResponse(Guitar guitar)
        {
            if (guitar == null)
            {
                return(null);
            }

            return(new GetGuitarResponse
            {
                Brand = guitar.Brand,
                Color = guitar.Color,
                Description = guitar.Description,
                Id = guitar.Id,
                Model = guitar.Model,
                PhotoLinks = guitar.PhotoLinks,
                StringQuantity = guitar.StringQuantity,
                Year = guitar.Year,
                Pickups = guitar.Pickups?.Select(p => new PickupModel
                {
                    Brand = p.Brand,
                    Model = p.Model,
                    Year = p.Year
                })?.ToList()
            });
        }
示例#13
0
        public void TestMessageWhenSetIsSuccessful()
        {
            IInstrument instrument = new Guitar();
            IPerformer  performer  = new Performer("Ivan", 20);

            performer.AddInstrument(instrument);

            ISong song = new Song("Song1", new TimeSpan(0, 1, 2));

            this.stage.AddSong(song);

            ISet set = new Short("Set1");

            set.AddPerformer(performer);
            set.AddSong(song);

            this.stage.AddSet(set);

            string actual = this.setController.PerformSets().Trim();

            string expected =
                "1. Set1:" + Environment.NewLine + "-- 1. Song1 (01:02)" + Environment.NewLine + "-- Set Successful";

            Assert.That(actual, Is.EqualTo(expected));
        }
        public void TestInstrumentsGetBroken()
        {
            IStage stage = new Stage();
            ISet   set   = new Short("Set1");

            TimeSpan duration = TimeSpan.FromSeconds((1 * 60) + 2);
            ISong    song     = new Song("Song1", duration);

            IPerformer performer = new Performer("Gosho", 20);

            IInstrument instrument = new Guitar();

            instrument.WearDown();
            instrument.WearDown();

            performer.AddInstrument(instrument);

            set.AddPerformer(performer);
            set.AddSong(song);

            stage.AddSong(song);

            stage.AddSet(set);
            stage.AddSong(song);
            stage.AddPerformer(performer);

            ISetController setController = new SetController(stage);

            string actual   = "1. Set1:\r\n-- Did not perform";
            string expected = setController.PerformSets();

            Assert.AreEqual(actual, expected);
        }
        public void PerforSetsTest()
        {
            IStage         stage         = new Stage();
            ISetController setController = new SetController(stage);
            ISet           set           = new Short("Set1");
            ISet           set2          = new Short("Set2");

            stage.AddSet(set);
            stage.AddSet(set2);
            IPerformer  performer = new Performer("Pesho", 23);
            IInstrument guitar    = new Guitar();

            stage.AddPerformer(performer);
            set.AddPerformer(performer);
            performer.AddInstrument(guitar);
            ISong song = new Song("Song1", new System.TimeSpan(0, 5, 0));

            stage.AddSong(song);
            set.AddSong(song);

            string expectedResult = "1. Set1:" + "\r\n" +
                                    "-- 1. Song1 (05:00)" + "\r\n" +
                                    "-- Set Successful" + "\r\n" +
                                    "2. Set2:" + "\r\n" +
                                    "-- Did not perform";


            string actualResult = setController.PerformSets();

            Assert.That(actualResult, Is.EqualTo(expectedResult).NoClip);
            Assert.That(guitar.Wear, Is.EqualTo(40));
        }
        public async Task <ActionResult> Put(Guitar guitar)
        {
            context.Entry(guitar).State = EntityState.Modified;
            await context.SaveChangesAsync();

            return(Ok());
        }
        public void SaveProduct(Guitar guitar, bool changedImage)
        {
            if (guitar.Id == 0)
            {
                context.Guitars.Add(guitar);
            }
            else
            {
                Guitar dbEntry = context.Guitars.Find(guitar.Id);
                if (dbEntry != null)
                {
                    dbEntry.Name        = guitar.Name;
                    dbEntry.Description = guitar.Description;
                    dbEntry.Price       = guitar.Price;
                    dbEntry.Category    = guitar.Category;
                    if (changedImage)
                    {
                        dbEntry.ImageData     = guitar.ImageData;
                        dbEntry.ImageMimeType = guitar.ImageMimeType;
                    }
                }
            }

            context.SaveChanges();
        }
示例#18
0
文件: Tests.cs 项目: SchineD/oom
 public void CannotCreateGuitarWithoutStatingBrand()
 {
     Assert.Catch(() =>
     {
         var x = new Guitar("", "Mustang", 2000m);
     });
 }
        public void PerfrormSets_ShouldDecrease_InstrumentWear()
        {
            //Arrange
            IStage         stage         = new Stage();
            ISetController setController = new SetController(stage);

            ISet        set        = new Short("Set1");
            IPerformer  performer  = new Performer("Gaga", 29);
            ISong       song       = new Song("Song", new TimeSpan(0, 2, 30));
            IInstrument instrument = new Guitar();

            //Act
            performer.AddInstrument(instrument);
            set.AddPerformer(performer);
            set.AddSong(song);
            stage.AddSet(set);

            double instrumentWearBefore = instrument.Wear;

            setController.PerformSets();
            double instrumentWearAfter = instrument.Wear;

            //Assert
            Assert.That(instrumentWearAfter, Is.Not.EqualTo(instrumentWearBefore));
        }
        public void TestWhetherTheControllerGivesCorrectOutput()
        {
            var set1 = new Short("set1");

            var performer  = new Performer("Bat nasko", 30);
            var instrument = new Guitar();

            performer.AddInstrument(instrument);
            var song = new Song("name", new TimeSpan(0, 0, 10, 0));

            var stage = new Stage();

            set1.AddPerformer(performer);
            set1.AddSong(song);
            stage.AddSet(set1);
            stage.AddPerformer(performer);
            stage.AddSong(song);

            var controller   = new SetController(stage);
            var stringOutput = controller.PerformSets();

            var expectedResult = "1. set1:\r\n-- 1. name (10:00)\r\n-- Set Successful";

            Assert.AreEqual(expectedResult, stringOutput);
        }
示例#21
0
        public async Task <IActionResult> AddNewGuitar(Guitar guitar)
        {
            db.Guitars.Add(guitar);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
示例#22
0
        static void Main(string[] args)
        {
            Music        music        = new Music(true, 3);
            Guitar       guitar       = new Guitar(15000, "Красное дерево");
            MusicStudent musicStudent = new MusicStudent(true, "Опытный блюзмен");

            Console.WriteLine("Слушаете ли вы музыку? - " + music.DoYouListenToMusic + "\nСколько вы играете" +
                              " на вашем инструменте? - " + music.YearsOfPlayingTheInstrument + " года\n");

            Console.WriteLine("Сколько стоит ваша гитара? - " + guitar.Cost + "\nИз какого она материала? - " +
                              guitar.Material + "\n");

            Console.WriteLine("Талантливый ли вы музыкант? - " + musicStudent.Talent + "\n" +
                              "Каким образом вы бы характеризовали себя, как музыканта? - " + musicStudent.SkillLevel + "\n");

            Console.WriteLine("(((((((((( Методы )))))))))\n----------------------------------------");
            music.WriteYourFavoriteMusicGenres("Rock, Indie, Pop");
            music.ToCreateSong("R&B");
            music.MusicIsPlaying();

            guitar.ToPlayTheGuitar();
            guitar.FixTheGuitar();
            guitar.BuyAGuitar();

            musicStudent.ToWalkToMusicSchool(false);
            musicStudent.ToTrainThePiano();
            musicStudent.ConductAnOrchestra();
        }
示例#23
0
        static void Main(string[] args)
        {
            Inventory inventory = new Inventory();

            initializeInventory(inventory);

            GuitarSpec whatErinLikes = new GuitarSpec(Model.Type.ELECTRIC, Builder.FENDER, Wood.ALDER, Wood.ALDER, "Stratocastor", 16);
            ArrayList  guitars       = inventory.Search(whatErinLikes);

            if (guitars.Count != 0)
            {
                Console.WriteLine("Erin, you might like these guitars : \n");
                foreach (var item in guitars)
                {
                    Guitar     guitar     = (Guitar)item;
                    GuitarSpec guitarSpec = (GuitarSpec)guitar.Spec;
                    Console.WriteLine(guitarSpec.GetBuilder + " " + guitarSpec.Model + "" +
                                      guitarSpec.GetInsType + " guitar:\n" +
                                      guitarSpec.BackWood + " back and sides,\n" +
                                      guitarSpec.NumStrings + " num strings are present" +
                                      guitarSpec.TopWood + " top.\nYou can have it for only $" +
                                      guitar.Price + "!");
                    Console.WriteLine();
                }
            }
            else
            {
                Console.WriteLine("Sorry, Erin, we have nothing for you.");
            }
        }
示例#24
0
        public void TestSetPerform()
        {
            var set = new Short("Set1");
            var instrumentGuitar = new Guitar();
            var instrumentDrums  = new Drums();
            var performer        = new Performer("Ivan", 23);
            var song1            = new Song("Song1", new TimeSpan(0, 1, 1));

            this.stage.AddSet(set);
            performer.AddInstrument(instrumentGuitar);
            performer.AddInstrument(instrumentDrums);
            set.AddPerformer(performer);
            set.AddSong(song1);


            var actual   = this.setController.PerformSets();
            var expected = $@"1. Set1:
-- 1. Song1 (01:01)
-- Set Successful";

            var actualInstrumentWear   = instrumentGuitar.Wear;
            var expectedInstrumentWear = 40;

            Assert.That(actual, Is.EqualTo(expected));
            Assert.That(actualInstrumentWear, Is.EqualTo(expectedInstrumentWear));
        }
        public void SetControllerShouldReturnSuccessMessage()
        {
            var stage = new Stage();

            var performer = new Performer("Ivo", 26);

            IInstrument instrument = new Guitar();

            performer.AddInstrument(instrument);

            stage.AddPerformer(performer); //

            ISong song = new Song("Chico loco", new TimeSpan(0, 2, 30));

            stage.AddSong(song); //

            ISet set = new Short("ShortSet");

            stage.AddSet(set);

            var setController = new SetController(stage);

            var actualResult   = setController.PerformSets();
            var expectedResult = "1. ShortSet:\r\n-- Did not perform";

            Assert.AreEqual(expectedResult, actualResult);
        }
示例#26
0
    public void PerformSetsShouldWearDownInstrument()
    {
        // Arrange
        ISet set1 = new Short("Set1");

        this.stage.AddSet(set1);

        IPerformer  performer  = new Performer("Ivan", 20);
        IInstrument instrument = new Guitar();

        performer.AddInstrument(instrument);
        this.stage.AddPerformer(performer);
        set1.AddPerformer(performer);

        ISong song = new Song("Song1", new TimeSpan(0, 1, 2));

        set1.AddSong(song);

        // Act
        string result = this.setController.PerformSets();

        // Assert
        double actualWear = instrument.Wear;

        Assert.That(actualWear, Is.EqualTo(40));
    }
        public void SetControllerShouldWearDownInstruments()
        {
            Performer   performer  = new Performer("Ivo", 26);
            IInstrument instrument = new Guitar();

            performer.AddInstrument(instrument);

            ISet set = new Short("ShortSet");

            set.AddPerformer(performer);
            ISong song = new Song("Chico loco", new TimeSpan(0, 2, 30));

            set.AddSong(song);

            var stage = new Stage();

            stage.AddPerformer(performer);
            stage.AddSong(song);
            stage.AddSet(set);

            var setController = new SetController(stage);

            var instrumentWearBefore = instrument.Wear;

            setController.PerformSets();

            var instrumentWearAfter = instrument.Wear;

            Assert.AreNotEqual(instrumentWearAfter, instrumentWearBefore);
        }
        public IHttpActionResult PutGuitar(int id, Guitar guitar)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != guitar.Id)
            {
                return(BadRequest());
            }

            db.Entry(guitar).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GuitarExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <ActionResult> Post(Guitar guitar)
        {
            context.Add(guitar);
            await context.SaveChangesAsync();

            return(new CreatedAtRouteResult("GetGuitar", new { id = guitar.Id }, guitar));
        }
示例#30
0
        public void PerformSets_WearDownTest()
        {
            IStage         stage      = new Stage();
            ISetController controller = new SetController(stage);

            ISet set = new Short("Set1");

            stage.AddSet(set);

            IPerformer  performer = new Performer("Sonny", 22);
            IInstrument guitar    = new Guitar();

            performer.AddInstrument(guitar);
            set.AddPerformer(performer);

            ISong song = new Song("Song", new TimeSpan(0, 3, 24));

            set.AddSong(song);

            var wearBeforeWearDown = guitar.Wear;

            controller.PerformSets();
            var afterWearDownWear = guitar.Wear;

            Assert.That(wearBeforeWearDown, Is.Not.EqualTo(afterWearDownWear));
        }
示例#31
0
            public override bool Test(Sim a, Guitar target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                if (!base.Test(a, target, isAutonomous, ref greyedOutTooltipCallback)) return false;

                if (SkillBasedCareerBooter.GetSkillBasedCareer(a, Sims3.Gameplay.Skills.SkillNames.Guitar) == null)
                {
                    return false;
                }

                if (a.SkillManager.GetSkillLevel(Sims3.Gameplay.Skills.SkillNames.Guitar) >= 5)
                {
                    return false;
                }

                return true;
            }
示例#32
0
        public void TestCompleted(ITest test, Guitar.Lib.TestResult result)
        {
            TestOutcome outcome = TestOutcome.None;
            switch (result.Outcome)
            {
                case TestStatus.Passed:
                    outcome = TestOutcome.Passed;
                    break;
                case TestStatus.Failed:
                    outcome = TestOutcome.Failed;
                    break;
                case TestStatus.Ignored:
                    outcome = TestOutcome.Skipped;
                    break;
            }
            TestCase testToStart = _expectedTests[createDictionaryKey(test)];
            _frameworkHandle.RecordEnd(testToStart, outcome);

            TestResult testresult = new TestResult(testToStart) {ErrorMessage = result.Message, Outcome = outcome};
            _frameworkHandle.RecordResult(testresult);
        }
        public ActionResult Create(Guitar.Entities.Guitars Model, string FInicio, string FPintura, string FPrueba, string FFin)
        {
            //String FInicio, FPintura, FPrueba, FFin;
            var model = this.GuitarService.GetOne(Convert.ToInt32(Model.Name));

            Model.Name = model.Name;
            Model.BodyID = model.BodyID;
            Model.BridgeID = model.BridgeID;
            Model.NeckID = model.NeckID;
            Model.PickupID = model.PickupID;

            Model.StartDate = Convert.ToDateTime(FInicio);
            Model.PaintDate = Convert.ToDateTime(FPintura);
            Model.TestDate = Convert.ToDateTime(FPrueba);
            Model.FinishDate = Convert.ToDateTime(FFin);

            if (!ModelState.IsValid)
            {
                ViewBag.Projects = this.GuitarService.GetAllProjects();
            }

            this.GuitarService.Create(Model);
            return RedirectToAction("Index");
        }
示例#34
0
 public override string GetInteractionName(Sim actor, Guitar target, InteractionObjectPair iop)
 {
     return base.GetInteractionName(actor, target, new InteractionObjectPair(Guitar.PlayForTips.Singleton, target));
 }
 public void Create(Guitar.Entities.Guitars Model)
 {
     var context = new GuitarDbContext();
     context.Guitar.Add(Model);
     context.SaveChanges();
 }
示例#36
0
 public override bool Test(Sim a, Guitar target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
 {
     return true;
 }