コード例 #1
0
        public void AddLogRequest_AllShouldbeCommited()
        {
            //arrange
            var cloudwatchClient = InitialiseClient();

            var logstream = Logstream + Guid.NewGuid();

            var cloudwatvhLogClient = new CloudWatchLogsClientWrapper(
                cloudwatchClient,
                LogGroup,
                logstream);

            cloudwatvhLogClient.InitialiseLogStream();

            var logevents = Builder <InputLogEvent>
                            .CreateListOfSize(20)
                            .All()
                            .With(x => x.Timestamp = DateTime.Now.AddDays(-1))
                            .Build()
                            .ToList();

            //act
            cloudwatvhLogClient.AddLogRequest(logevents);

            Thread.Sleep(2000);

            var results = cloudwatchClient.GetLogEvents(new GetLogEventsRequest(
                                                            LogGroup,
                                                            logstream));

            //assert
            results.Events.Count.Should().Equal(20);
            results.Events.All(x => string.IsNullOrEmpty(x.Message));
            results.Events.All(x => x.Timestamp != new DateTime());
        }
コード例 #2
0
        public void InitialiseLogStream_Verify_CreateLogStream()
        {
            //arrange
            var container = new AutoMoqer();

            var amazonclientMock = container.GetMock <IAmazonCloudWatchLogs>();

            amazonclientMock.SetupSequence(x => x.DescribeLogStreams(It.IsAny <DescribeLogStreamsRequest>()))
            .Returns(new DescribeLogStreamsResponse
            {
                LogStreams = new List <LogStream>()
            })
            .Returns(new DescribeLogStreamsResponse
            {
                LogStreams = new List <LogStream>
                {
                    new LogStream
                    {
                        LogStreamName = Logstream
                    }
                }
            });

            var target = new CloudWatchLogsClientWrapper(amazonclientMock.Object, LogGroup, Logstream);

            //act
            target.InitialiseLogStream();

            //assert
            amazonclientMock.Verify(x => x.CreateLogStream(It.IsAny <CreateLogStreamRequest>()));
        }
コード例 #3
0
        public void InitialiseLogStream_Test()
        {
            //arrange
            var cloudwatchClient = InitialiseClient();

            var cloudwatvchLogClient = new CloudWatchLogsClientWrapper(cloudwatchClient, LogGroup, Logstream);

            cloudwatvchLogClient.InitialiseLogStream();

            //act
            var results = cloudwatchClient.DescribeLogStreams(new DescribeLogStreamsRequest(LogGroup));

            //assert
            results.LogStreams.Count().Should().Equal(1);
            results.LogStreams.Any(x => x.LogStreamName == Logstream).Should().Be.True();
        }