Ejemplo n.º 1
0
    public async Task Map_MetadataLookup_ReturnsLookupItems() {

      var mappingService        = new TopicMappingService(_topicRepository, new FakeViewModelLookupService());
      var topic                 = TopicFactory.Create("Test", "MetadataLookup");

      var target                = (MetadataLookupTopicViewModel?)await mappingService.MapAsync(topic).ConfigureAwait(false);

      Assert.AreEqual<int>(5, target.Categories.Count);

    }
Ejemplo n.º 2
0
    public async Task Map_TopicReferences_ReturnsMappedModel() {

      var mappingService        = new TopicMappingService(_topicRepository, new FakeViewModelLookupService());
      var topicReference        = _topicRepository.Load(11111);

      var topic                 = TopicFactory.Create("Test", "TopicReference");

      topic.Attributes.SetInteger("TopicReferenceId", topicReference.Id);

      var target                = (TopicReferenceTopicViewModel?)await mappingService.MapAsync(topic).ConfigureAwait(false);

      Assert.IsNotNull(target.TopicReference);
      Assert.AreEqual<string>(topicReference.Key, target.TopicReference.Key);

    }
    public async Task TopicController_IndexAsync() {

      var topicRoutingService   = new MvcTopicRoutingService(_topicRepository, _uri, _routeData);
      var mappingService        = new TopicMappingService(_topicRepository, new TopicViewModelLookupService());

      var controller            = new TopicController(_topicRepository, topicRoutingService, mappingService);
      var result                = await controller.IndexAsync(_topic.GetWebPath()).ConfigureAwait(false) as TopicViewResult;
      var model                 = result.Model as PageTopicViewModel;

      controller.Dispose();

      Assert.IsNotNull(model);
      Assert.AreEqual<string>("Web_0_1_1", model.Title);

    }
Ejemplo n.º 4
0
    /*==========================================================================================================================
    | METHOD: INVOKE (ASYNC)
    \-------------------------------------------------------------------------------------------------------------------------*/
    /// <summary>
    ///   Provides the pagel-level navigation menu for the current page, which exposes one tier of navigation from the nearest
    ///   page group.
    /// </summary>
    public async Task<IViewComponentResult> InvokeAsync(bool moveNext) {

      /*------------------------------------------------------------------------------------------------------------------------
      | Identify adjacent topic
      \-----------------------------------------------------------------------------------------------------------------------*/
      var adjacentTopic         = GetAdjacentTopic(CurrentTopic.Parent, CurrentTopic, moveNext);
      var label                 = moveNext? "Next Lesson" : "Previous Lesson";

      /*------------------------------------------------------------------------------------------------------------------------
      | Fallback to adjacent unit
      \-----------------------------------------------------------------------------------------------------------------------*/
      if (adjacentTopic is null) {
        var adjacentUnit        = GetAdjacentTopic(CurrentTopic.Parent.Parent, CurrentTopic.Parent, moveNext);
        if (adjacentUnit is not null) {
          adjacentTopic         = moveNext? adjacentUnit.Children.FirstOrDefault() : adjacentUnit.Children.LastOrDefault();
          label                 = moveNext? "Next Unit" : "Previous Unit";
        }
      }

      /*------------------------------------------------------------------------------------------------------------------------
      | Fallback to course
      \-----------------------------------------------------------------------------------------------------------------------*/
      if (adjacentTopic is null) {
        adjacentTopic           = CurrentTopic.Parent.Parent;
        label                   = moveNext? "Finish Course" : "Return to Syllabus";
      }

      /*------------------------------------------------------------------------------------------------------------------------
      | Map adjacent topic
      \-----------------------------------------------------------------------------------------------------------------------*/
      var topicViewModel        = new LessonPagingTopicViewModel {
        Label                   = label,
        MoveNext                = moveNext
      };
      topicViewModel            = (LessonPagingTopicViewModel)await TopicMappingService.MapAsync(adjacentTopic, topicViewModel).ConfigureAwait(true);

      /*------------------------------------------------------------------------------------------------------------------------
      | Return the corresponding view
      \-----------------------------------------------------------------------------------------------------------------------*/
      return View(topicViewModel);

    }