LCOV - code coverage report
Current view: top level - Cqrs.WebApi - HelpPageConfig.cs Hit Total Coverage
Test: doc-coverage.info Lines: 0 4 0.0 %
Date: 2017-07-26

          Line data    Source code
       1             : #region Copyright
       2             : // // -----------------------------------------------------------------------
       3             : // // <copyright company="cdmdotnet Limited">
       4             : // //   Copyright cdmdotnet Limited. All rights reserved.
       5             : // // </copyright>
       6             : // // -----------------------------------------------------------------------
       7             : #endregion
       8             : 
       9             : using System;
      10             : using System.Collections.Generic;
      11             : using System.Reflection;
      12             : using System.Runtime.Serialization;
      13             : using System.Web;
      14             : using System.Xml;
      15             : using Cqrs.Authentication;
      16             : using Cqrs.Events;
      17             : using Cqrs.Messages;
      18             : using Cqrs.Services;
      19             : 
      20             : namespace Cqrs.WebApi
      21             : {
      22             :         public static class HelpPageConfig<TSingleSignOnToken>
      23             :                 where TSingleSignOnToken : ISingleSignOnToken, new()
      24           0 :         {
      25             :                 public class UserCreatedEvent : IEvent<TSingleSignOnToken>
      26           0 :                 {
      27             :                         #region Implementation of IEvent
      28             : 
      29             :                         [DataMember]
      30             :                         public Guid Id
      31             :                         {
      32             :                                 get
      33             :                                 {
      34             :                                         return Rsn;
      35             :                                 }
      36             :                                 set
      37             :                                 {
      38             :                                         Rsn = value;
      39             :                                 }
      40             :                         }
      41             : 
      42             :                         [DataMember]
      43             :                         public int Version { get; set; }
      44             : 
      45             :                         [DataMember]
      46             :                         public DateTimeOffset TimeStamp { get; set; }
      47             : 
      48             :                         #endregion
      49             : 
      50             :                         #region Implementation of IMessageWithAuthenticationToken<TSingleSignOnToken>
      51             : 
      52             :                         [DataMember]
      53             :                         public TSingleSignOnToken AuthenticationToken { get; set; }
      54             : 
      55             :                         #endregion
      56             : 
      57             :                         #region Implementation of IMessage
      58             : 
      59             :                         [DataMember]
      60             :                         public Guid CorrelationId { get; set; }
      61             : 
      62             :                         [DataMember]
      63             :                         [Obsolete("Use Frameworks, It's far more flexible and OriginatingFramework")]
      64             :                         public FrameworkType Framework { get; set; }
      65             : 
      66             :                         /// <summary>
      67             :                         /// The originating framework this message was sent from.
      68             :                         /// </summary>
      69             :                         [DataMember]
      70             :                         public string OriginatingFramework { get; set; }
      71             : 
      72             :                         /// <summary>
      73             :                         /// The frameworks this <see cref="IMessage"/> has been delivered to/sent via already.
      74             :                         /// </summary>
      75             :                         [DataMember]
      76             :                         public IEnumerable<string> Frameworks { get; set; }
      77             : 
      78             :                         [Obsolete("Use CorrelationId")]
      79             :                         [DataMember]
      80             :                         public Guid CorrolationId
      81             :                         {
      82             :                                 get { return CorrelationId; }
      83             :                                 set { CorrelationId = value; }
      84             :                         }
      85             : 
      86             :                         #endregion
      87             : 
      88             :                         public Guid Rsn { get; set; }
      89             : 
      90             :                         public string Name { get; set; }
      91             : 
      92             :                         public string EmailAddress { get; set; }
      93             :                 }
      94             : 
      95           0 :                 public static IDictionary<Type, object> GetBasicSampleObjects()
      96             :                 {
      97             :                         var eventCorrelationId = Guid.NewGuid();
      98             :                         var correlationId = Guid.NewGuid();
      99             : 
     100             :                         var authenticationToken = new TSingleSignOnToken
     101             :                         {
     102             :                                 Token = Guid.NewGuid().ToString("N"),
     103             :                                 DateIssued = DateTime.Now,
     104             :                                 TimeOfExpiry = DateTime.Now.AddMinutes(20)
     105             :                         };
     106             : 
     107             :                         var sameplEvent = new UserCreatedEvent
     108             :                         {
     109             :                                 CorrelationId = correlationId,
     110             :                                 AuthenticationToken = authenticationToken,
     111             :                                 EmailAddress = "john@smith.com",
     112             :                                 Frameworks = new List<string> { "Azure", "Amazon EC2" },
     113             :                                 Id = Guid.NewGuid(),
     114             :                                 Name = "John Smith",
     115             :                                 OriginatingFramework = "Azure",
     116             :                                 TimeStamp = DateTime.Now.AddMinutes(-3),
     117             :                                 Version = 1
     118             :                         };
     119             : 
     120             :                         return new Dictionary<Type, object>
     121             :                         {
     122             :                                 {
     123             :                                         typeof(string),
     124             :                                         "sample string"
     125             :                                 },
     126             :                                 {
     127             :                                         typeof(IServiceResponse),
     128             :                                         new ServiceResponse
     129             :                                         {
     130             :                                                 CorrelationId = correlationId,
     131             :                                                 State = ServiceResponseStateType.Succeeded
     132             :                                         }
     133             :                                 },
     134             :                                 {
     135             :                                         typeof(IServiceRequestWithData<TSingleSignOnToken, Guid>),
     136             :                                         new ServiceRequestWithData<TSingleSignOnToken, Guid>
     137             :                                         {
     138             :                                                 AuthenticationToken = new TSingleSignOnToken
     139             :                                                 {
     140             :                                                         Token = Guid.NewGuid().ToString("N"),
     141             :                                                         DateIssued = DateTime.Now,
     142             :                                                         TimeOfExpiry = DateTime.Now.AddMinutes(20)
     143             :                                                 },
     144             :                                                 CorrelationId = correlationId,
     145             :                                                 Data = eventCorrelationId
     146             :                                         }
     147             :                                 },
     148             :                                 {
     149             :                                         typeof(IServiceResponseWithResultData<IEnumerable<EventData>>),
     150             :                                         new ServiceResponseWithResultData<IEnumerable<EventData>>
     151             :                                         {
     152             :                                                 CorrelationId = correlationId,
     153             :                                                 ResultData = new List<EventData>
     154             :                                                 {
     155             :                                                         new EventData
     156             :                                                         {
     157             :                                                                 AggregateId = string.Format("{0}//{1}", typeof(UserCreatedEvent).FullName, sameplEvent.Rsn),
     158             :                                                                 CorrelationId = eventCorrelationId,
     159             :                                                                 Data = sameplEvent,
     160             :                                                                 AggregateRsn = sameplEvent.Rsn,
     161             :                                                                 EventId = Guid.NewGuid(),
     162             :                                                                 EventType = typeof(UserCreatedEvent).FullName,
     163             :                                                                 Timestamp = sameplEvent.TimeStamp.DateTime,
     164             :                                                                 Version = sameplEvent.Version
     165             :                                                         }
     166             :                                                 },
     167             :                                                 Version = 0,
     168             :                                                 State = ServiceResponseStateType.Succeeded
     169             :                                         }
     170             :                                 }
     171             :                         };
     172             :                 }
     173             : 
     174           0 :                 public static void CreateXmlDocumentation()
     175             :                 {
     176             :                         XmlDocument cqrsDocumentation = new XmlDocument();
     177             :                         cqrsDocumentation.Load(HttpContext.Current.Server.MapPath("~/bin/Cqrs.xml"));
     178             : 
     179             :                         string webAssemblyName = Assembly.GetCallingAssembly().FullName;
     180             :                         webAssemblyName = webAssemblyName.Substring(0, webAssemblyName.IndexOf(","));
     181             :                         XmlDocument finalDocumentation = new XmlDocument();
     182             :                         finalDocumentation.Load(HttpContext.Current.Server.MapPath("~/bin/" + webAssemblyName + ".XML"));
     183             :                         foreach (XmlNode childNode in cqrsDocumentation.DocumentElement.ChildNodes)
     184             :                                 finalDocumentation.DocumentElement.AppendChild(finalDocumentation.ImportNode(childNode, true));
     185             : 
     186             :                         string publicAssemblyName = webAssemblyName.Substring(0, webAssemblyName.Length - ".Domain.Host.Web".Length);
     187             :                         XmlDocument publicDocumentation = new XmlDocument();
     188             :                         publicDocumentation.Load(HttpContext.Current.Server.MapPath("~/bin/" + publicAssemblyName + ".XML"));
     189             :                         foreach (XmlNode childNode in publicDocumentation.DocumentElement.ChildNodes)
     190             :                                 finalDocumentation.DocumentElement.AppendChild(finalDocumentation.ImportNode(childNode, true));
     191             : 
     192             :                         string domainAssemblyName = webAssemblyName.Substring(0, webAssemblyName.Length - ".Host.Web".Length);
     193             :                         XmlDocument domainDocumentation = new XmlDocument();
     194             :                         domainDocumentation.Load(HttpContext.Current.Server.MapPath("~/bin/" + domainAssemblyName + ".XML"));
     195             :                         foreach (XmlNode childNode in domainDocumentation.DocumentElement.ChildNodes)
     196             :                                 finalDocumentation.DocumentElement.AppendChild(finalDocumentation.ImportNode(childNode, true));
     197             : 
     198             :                         finalDocumentation.Save(HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml"));
     199             :                 }
     200             :         }
     201             : }

Generated by: LCOV version 1.10