Пример #1
0
        public async Task <SampleSets> DeleteSampleSetsAsync(SampleSets sampleSets2BDeleted)
        {
            _context.SampleSet.Remove(sampleSets2BDeleted);
            await _context.SaveChangesAsync();

            return(sampleSets2BDeleted);
        }
Пример #2
0
        public async Task <SampleSets> AddSampleSetsAsync(SampleSets newSampleSets)
        {
            await _context.SampleSet.AddAsync(newSampleSets);

            await _context.SaveChangesAsync();

            return(newSampleSets);
        }
Пример #3
0
 /// <summary>
 ///     使用两种音效,编号,音量,和文件名构造一个HitSample对象
 /// </summary>
 /// <param name="normalSet"></param>
 /// <param name="additionSet"></param>
 /// <param name="index"></param>
 /// <param name="volume"></param>
 /// <param name="fileName"></param>
 public HitSample(SampleSets normalSet, SampleSets additionSet, int index, int volume, string fileName)
 {
     NormalSet   = normalSet;
     AdditionSet = additionSet;
     Index       = index;
     Volume      = volume;
     FileName    = !string.IsNullOrEmpty(fileName) ? fileName : "";
 }
Пример #4
0
        public async Task <SampleSets> UpdateSampleSetsAsync(SampleSets sampleSet2BUpdated)
        {
            SampleSets oldSampleSets = await _context.SampleSet.Where(s => s.Id == sampleSet2BUpdated.Id).FirstOrDefaultAsync();

            _context.Entry(oldSampleSets).CurrentValues.SetValues(sampleSet2BUpdated);

            await _context.SaveChangesAsync();

            _context.ChangeTracker.Clear();
            return(oldSampleSets);
        }
Пример #5
0
        //SampleSets 
        public async Task<SampleSets> AddSampleSetsAsync(SampleSets newSampleSets, int userId)
        {
            newSampleSets = await _repo.AddSampleSetsAsync(newSampleSets);
            UsersSampleSets usersSampleSets = new UsersSampleSets();
            usersSampleSets.SampleSetsId = newSampleSets.Id;
            usersSampleSets.UserId = userId;
            usersSampleSets.IsOwner = true;
            await _repo.AddUsersSampleSetsAsync(usersSampleSets);
            return await _repo.GetSampleSetsByIDAsync(newSampleSets.Id);

        }
Пример #6
0
        public async Task UpdateSampleSetsShouldUpdateSampleSets()
        {
            var sample = new SampleSets {
                Id = 1
            };

            _projectBLMock.Setup(x => x.UpdateSampleSetsAsync(It.IsAny <SampleSets>())).Returns(Task.FromResult(sample));
            var sampleController = new SampleSetsController(_projectBLMock.Object);
            var result           = await sampleController.UpdateSampleSetsAsync(sample.Id, sample);

            Assert.IsAssignableFrom <NoContentResult>(result);
            _projectBLMock.Verify(x => x.UpdateSampleSetsAsync(sample));
        }
        public async Task <IActionResult> UpdateSampleSetsAsync(int id, [FromBody] SampleSets sampleSets)
        {
            try
            {
                await _projectBL.UpdateSampleSetsAsync(sampleSets);

                return(NoContent());
            }
            catch
            {
                return(StatusCode(500));
            }
        }
Пример #8
0
        public async Task GetSampleSetsByIdShouldGetSampleSet()
        {
            var sampleId = 1;
            var sample   = new SampleSets {
                Id = sampleId
            };

            _projectBLMock.Setup(x => x.GetSampleSetsByIDAsync(It.IsAny <int>())).Returns(Task.FromResult(sample));
            var sampleController = new SampleSetsController(_projectBLMock.Object);
            var result           = await sampleController.GetSampleSetsByIDAsync(sampleId);

            Assert.Equal(sampleId, ((SampleSets)((OkObjectResult)result).Value).Id);
            _projectBLMock.Verify(x => x.GetSampleSetsByIDAsync(sampleId));
        }
Пример #9
0
        public async Task GetSampleSetsAsyncShouldReturnSampleSets()
        {
            //arrange
            SampleSets sample = new SampleSets();

            _projectBLMock.Setup(i => i.GetSampleSetsAsync());
            SampleSetsController sampleController = new SampleSetsController(_projectBLMock.Object);

            //act
            var result = await sampleController.GetSampleSetsAsync();

            //assert
            Assert.IsType <OkObjectResult>(result);
        }
Пример #10
0
        public async Task GetSampleSetsByID_ShouldReturnNotFound_WhenIDIsInvalid()
        {
            //arrange
            int        id         = 1;
            SampleSets sampleSets = null;

            _projectBLMock.Setup(i => i.GetSampleSetsByIDAsync(id)).ReturnsAsync(sampleSets);
            SampleSetsController sampleSetsController = new SampleSetsController(_projectBLMock.Object);

            //act
            var result = await sampleSetsController.GetSampleSetsByIDAsync(id);

            //assert
            Assert.IsType <NotFoundResult>(result);
        }
Пример #11
0
        public async Task AddSampleSetsAsync_ShouldReturnStatusCode400_WhenSampleSetsIsInvalid()
        {
            //arrange
            SampleSets sampleSets = null;
            int        id         = -1;

            _projectBLMock.Setup(i => i.AddSampleSetsAsync(sampleSets, id)).Throws(new Exception());
            SampleSetsController sampleSetsController = new SampleSetsController(_projectBLMock.Object);

            //act
            var result = await sampleSetsController.AddSampleSetsAsync();

            //assert
            Assert.IsType <StatusCodeResult>(result);
            Assert.Equal(400, ((StatusCodeResult)result).StatusCode);
        }
        public async Task UpdateSampleSetsAsync_ShouldReturnOldSampleSets()
        {
            //arrange
            SampleSets sampleSets = new SampleSets
            {
                Id   = 1,
                Name = "New sample sets name"
            };
            ProjectDBContext projectDBContext = new ProjectDBContext(options);
            ProjectRepoDB    projectRepoDB    = new ProjectRepoDB(projectDBContext);

            //act
            var result = await projectRepoDB.UpdateSampleSetsAsync(sampleSets);

            //assert
            Assert.Equal(sampleSets.Name, result.Name);
        }
        public async Task <IActionResult> AddSampleSetsAsync()
        {
            try
            {
                SampleSets sampleSets = new SampleSets();
                sampleSets.Name = Request.Form["name"];
                sampleSets.Id   = 0;
                string userId = Request.Form["userId"];
                await _projectBL.AddSampleSetsAsync(sampleSets, int.Parse(userId));

                //Log.Logger.Information($"new SampleSets with ID {sampleSets.Id} created");
                return(CreatedAtAction("AddSampleSets", sampleSets));
            }
            catch (Exception e)
            {
                Log.Logger.Error($"Error thrown: {e.Message}");
                return(StatusCode(400));
            }
        }
Пример #14
0
 /// <summary>
 ///     使用普通音效和附加音效初始化一个EdgeSound对象
 /// </summary>
 /// <param name="normalSet"></param>
 /// <param name="additionSet"></param>
 public EdgeSound(SampleSets normalSet = SampleSets.Default, SampleSets additionSet = SampleSets.Default)
 {
     NormalSet   = normalSet;
     AdditionSet = additionSet;
 }
Пример #15
0
 public async Task<SampleSets> UpdateSampleSetsAsync(SampleSets sampleSet2BUpdated)
 {
     return await _repo.UpdateSampleSetsAsync(sampleSet2BUpdated);
 }
Пример #16
0
 public async Task<SampleSets> DeleteSampleSetsAsync(SampleSets sampleSets2BDeleted)
 {
     return await _repo.DeleteSampleSetsAsync(sampleSets2BDeleted);
 }
Пример #17
0
 /// <summary>
 ///     使用<seealso cref="HitSounds" />和两个<seealso cref="SampleSets" />构造一个SliderHitSound
 /// </summary>
 /// <param name="hitSound"></param>
 /// <param name="sampleSets"></param>
 /// <param name="additionSampleSet"></param>
 public SliderHitSound(HitSounds hitSound, SampleSets sampleSets, SampleSets additionSampleSet)
 {
     HitSound = hitSound;
     Sound    = new EdgeSound(sampleSets, additionSampleSet);
 }