Пример #1
0
        public async Task GetAllDescriptionsByServiceAsync()
        {
            var service          = new DescriptionService();
            var listDescriptions = await service.GetAllDescriptionsByInterestPoint(SelectedInterestPoint.InterestPoint.IdInterestPoint, Token.tokenCurrent);

            ListDescriptions = new ObservableCollection <DescriptionWithVote>(listDescriptions);
        }
Пример #2
0
        static void Main(string[] args)
        {
            using (ModuleReader mr = new ModuleReader(@"D:\log4net.dll"))
            {
                var module = mr.ReadNetModule();

                DescriptionService <HeaderDescriptionInfo> s = new DescriptionService <HeaderDescriptionInfo>();
                var md = s.GetFieldDescription(module).ToList();

                foreach (var m in md.OrderBy(n => n.HeaderOrderNumber))
                {
                    Console.WriteLine($"HeaderOrderNumber {m.HeaderOrderNumber}");
                    Console.WriteLine($"Header description: {m.Description}");
                    foreach (var hm in m.HeaderMemberDescriptions.OrderBy(n => n.FieldOffset))
                    {
                        Console.WriteLine($"FieldName : {hm.FieldName}");
                        Console.WriteLine($"FieldOffset : {hm.FieldOffset}");
                        Console.WriteLine($"FieldLength : {hm.FieldLength}");
                        Console.WriteLine($"FieldValue : {hm.FieldValue}");
                        Console.Write("Bytes : ");
                        foreach (var b in hm.ValueBytes)
                        {
                            Console.Write($"{b};");
                        }
                        Console.WriteLine();
                        Console.WriteLine($"Description : {hm.Description}");
                        Console.WriteLine(hm.Description);
                    }

                    Console.WriteLine();
                }

                Console.Read();
            }
        }
Пример #3
0
        //Get: Description/Delete
        public ActionResult Delete(int id)
        {
            var service     = new DescriptionService();
            var description = service.GetDescription(id);

            return(View(description));
        }
Пример #4
0
        // GET: Description Index
        public ActionResult Index()
        {
            var service = new DescriptionService();
            var model   = service.GetDescriptions();

            return(View(model));
        }
Пример #5
0
        public async Task ReturnsBadRequestIfPokemonDoesNotExist(string name)
        {
            DescriptionService
            .Setup(s => s.GetShakespeareanDescription(It.IsAny <string>()))
            .ReturnsAsync(new Monad <string>(new KeyNotFoundException()));

            var result = await Controller.GetShakespeareanDescription(name);

            Assert.IsType <BadRequestObjectResult>(result);
        }
Пример #6
0
 public EventDescription PostSave(EventDescription description)
 {
     if (description.Id > 0)
     {
         return(DescriptionService.UpdateDescription(description));
     }
     else
     {
         return(DescriptionService.CreateDescription(description));
     }
 }
Пример #7
0
        public async Task ThrowsOnIllegalResult()
        {
            DescriptionService
            .Setup(s => s.GetShakespeareanDescription(It.IsAny <string>()))
            .ReturnsAsync(new Monad <string>(result: null !));

            var exception = await Assert.ThrowsAsync <InvalidOperationException>(
                async() => await Controller.GetShakespeareanDescription("mew"));

            Assert.Null(exception.InnerException);
        }
 public override IEnumerable<HeaderMemberDescriptionInfo> GetPropertyDescriptionInfo<T>(PropertyInfo property, Attribute attribute, T header)
 {
     int dataDirectoriesOffset = GetOffset(attribute);
     var headerDescriptionService = new DescriptionService<HeaderMemberDescriptionInfo>();
     var propertyToGetDescription = property.GetValue(header);
     foreach (var headerDescription in headerDescriptionService.GetFieldDescription(propertyToGetDescription))
     {
         headerDescription.FieldOffset += dataDirectoriesOffset;
         yield return headerDescription;
     }
 }
Пример #9
0
        public async Task ReturnsTooManyRequestsIfAnyLimitIsExceeded(string name)
        {
            DescriptionService
            .Setup(s => s.GetShakespeareanDescription(It.IsAny <string>()))
            .ReturnsAsync(new Monad <string>(new LimitExceededException()));

            var result = await Controller.GetShakespeareanDescription(name);

            var statusCodeResult = Assert.IsType <StatusCodeResult>(result);

            Assert.Equal(StatusCodes.Status429TooManyRequests, statusCodeResult.StatusCode);
        }
Пример #10
0
        public async Task PokemonNameIsAlwaysPassedLowercase(string name)
        {
            DescriptionService
#pragma warning disable CA1308 // We actually want ToLowerInvariant
            .Setup(s => s.GetShakespeareanDescription(name.ToLowerInvariant()))
#pragma warning restore CA1308
            .ReturnsAsync(new Monad <string>("Dummy"))
            .Verifiable();

            var result = await Controller.GetShakespeareanDescription(name);

            DescriptionService.VerifyAll();
        }
Пример #11
0
        //Get: Description/Edit/{id}
        public ActionResult Edit(int id)
        {
            var service = new DescriptionService();
            var detail  = service.GetDescription(id);
            var model   =
                new DescriptionEdit
            {
                DescriptionId   = detail.DescriptionId,
                DescriptionName = detail.DescriptionName,
            };

            return(View(model));
        }
Пример #12
0
        public async Task ReturnedNameMatchesParameter(string name, string description)
        {
            DescriptionService
            .Setup(s => s.GetShakespeareanDescription(It.IsAny <string>()))
            .ReturnsAsync(new Monad <string>(description));

            var result = await Controller.GetShakespeareanDescription(name);

            var okResult = Assert.IsType <OkObjectResult>(result);
            var response = Assert.IsType <PokemonResponse>(okResult.Value);

            Assert.Equal(name, response.Name);
        }
Пример #13
0
        public async Task ThrowsOnUnexpectedError()
        {
            var expected = new ArgumentException();

            DescriptionService
            .Setup(s => s.GetShakespeareanDescription(It.IsAny <string>()))
            .ReturnsAsync(new Monad <string>(expected));

            var exception = await Assert.ThrowsAsync <InvalidOperationException>(
                async() => await Controller.GetShakespeareanDescription("mew"));

            Assert.Same(expected, exception.InnerException);
        }
Пример #14
0
        public ActionResult DeletePost(int id)
        {
            var service = new DescriptionService();

            if (service.DeleteDescription(id))
            {
                TempData["SaveResult"] = "Description Deleted";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Description could not be updated");
            var model = service.GetDescription(id);

            return(View(model));
        }
Пример #15
0
        public override IEnumerable <HeaderDescriptionInfo> GetPropertyDescriptionInfo <T>(PropertyInfo property, Attribute attribute, T header)
        {
            int    headerOrderNumber        = GetOrderNumber(attribute);
            string description              = GetDescription(attribute);
            var    headerDescriptionService = new DescriptionService <HeaderMemberDescriptionInfo>();
            var    propertyToGetDescription = property.GetValue(header);
            IEnumerable <HeaderMemberDescriptionInfo> headerMemberDescriptions = headerDescriptionService.GetFieldDescription(propertyToGetDescription);

            yield return(new HeaderDescriptionInfo
            {
                Description = description,
                HeaderMemberDescriptions = headerMemberDescriptions,
                HeaderOrderNumber = headerOrderNumber,
            });
        }
Пример #16
0
        public async Task DeleteDescriptionAsync()
        {
            var service    = new DescriptionService();
            int resultCode = await service.DeleteDescriptionById(SelectedDescription.Description.IdDescription, Token.tokenCurrent);

            if (resultCode == 200)
            {
                MessengerInstance.Send <DescriptionWithVote>(SelectedDescription, "deleteDescription");
            }
            else
            {
                var messageDialog = new Windows.UI.Popups.MessageDialog("L'élément à supprimer est introuvable");
                await messageDialog.ShowAsync();
            }
            _navigationService.GoBack();
        }
Пример #17
0
        public ActionResult Edit(int id, DescriptionEdit model)
        {
            var service = new DescriptionService();

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (service.UpdateDescription(id, model))
            {
                TempData["SaveResult"] = "Description Updated";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Description could not be updated");
            return(View(model));
        }
Пример #18
0
        public ActionResult Create(DescriptionCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = new DescriptionService();

            if (service.CreateDescription(model))
            {
                TempData["SaveResult"] = "Description Created";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Description could not be added");
            return(View(model));
        }
Пример #19
0
 public IEnumerable <EventDescription> GetAll()
 {
     return(DescriptionService.GetAllDescriptions());
 }
Пример #20
0
 public EventDescription GetById(int id)
 {
     return(DescriptionService.GetDescriptionById(id));
 }
Пример #21
0
 public int DeleteById(int id)
 {
     return(DescriptionService.DeleteDescription(id));
 }
Пример #22
0
        public ActionResult About()
        {
            this.ViewBag.Message = DescriptionService.GetWebApplicationDescription();

            return(View());
        }