Exemplo n.º 1
0
        public void FixtureSetup()
        {
            HttpClientMock = MockRepository.GenerateMock <IHttpClient>();
            Client         = new RestBroadcastClient(HttpClientMock);

            BroadcastId        = 1;
            GetBroadcastStats  = new CfGetBroadcastStats(BroadcastId, DateTime.Now, DateTime.Now);
            ExpectedUsageStats = new BroadcastStatsUsageStats(5, 5, 2, 10, 2);

            var resultStat = new BroadcastStatsResultStat[1];

            ExpectedResultStat = new BroadcastStatsResultStat("result", 2, 3);
            resultStat[0]      = ExpectedResultStat;

            ExpectedActionsStatistics = new BroadcastStatsActionStatistics(2, 0, 10);

            var expectedBroadcastStats = new BroadcastStats(ExpectedUsageStats, resultStat, ExpectedActionsStatistics);

            var resource = new Resource {
                Resources = expectedBroadcastStats
            };
            var        serializer = new XmlSerializer(typeof(Resource));
            TextWriter writer     = new StringWriter();

            serializer.Serialize(writer, resource);

            HttpClientMock
            .Stub(j => j.Send(Arg <string> .Is.Equal(String.Format("/broadcast/{0}/stats", BroadcastId)),
                              Arg <HttpMethod> .Is.Equal(HttpMethod.Get),
                              Arg <object> .Is.Anything))
            .Return(writer.ToString());
        }
 internal static BroadcastStatsResultStat[] ToSoapBroadcastResultStat(CfBroadcastStatsResultStat[] source)
 {
     BroadcastStatsResultStat[] result = null;
     if (source != null)
     {
         result = new BroadcastStatsResultStat[source.Count()];
         for (var i = 0; i < source.Count(); i++)
         {
             var item = source[i];
             if (item != null)
             {
                 result[i] = new BroadcastStatsResultStat(item.Result, item.Attempts, item.Actions);
             }
         }
     }
     return(result);
 }
        public void FixtureSetup()
        {
            BroadcastServiceMock = MockRepository.GenerateStub <IBroadcastServicePortTypeClient>();
            Client = new SoapBroadcastClient(BroadcastServiceMock);

            BroadcastId        = 1;
            GetBroadcastStats  = new CfGetBroadcastStats(BroadcastId, DateTime.Now, DateTime.Now);
            ExpectedUsageStats = new BroadcastStatsUsageStats(5, 5, 2, 10, 2);

            var resultStat = new BroadcastStatsResultStat[1];

            ExpectedResultStat = new BroadcastStatsResultStat("result", 2, 3);
            resultStat[0]      = ExpectedResultStat;

            ExpectedActionsStatistics = new BroadcastStatsActionStatistics(2, 0, 10);

            var expectedBroadcastStats = new BroadcastStats(ExpectedUsageStats, resultStat, ExpectedActionsStatistics);

            BroadcastServiceMock
            .Stub(b => b.GetBroadcastStats(Arg <GetBroadcastStats> .Matches(x => x.Id == BroadcastId)))
            .Return(expectedBroadcastStats);
        }
 public BroadcastStats(BroadcastStatsUsageStats usageStats, BroadcastStatsResultStat[] resultStat, BroadcastStatsActionStatistics actionStatistics)
 {
     UsageStats = usageStats;
     ResultStat = resultStat;
     ActionStatistics = actionStatistics;
 }