Example #1
0
        protected static void Initialize()
        {
            ExceptionHandlerMock = new Mock <IExceptionHandler>();
            Handler = new Handler(ExceptionHandlerMock.Object);
            RemarkRepositoryMock      = new Mock <IRemarkRepository>();
            RemarkRepositoryMock      = new Mock <IRemarkRepository>();
            GroupRemarkRepositoryMock = new Mock <IGroupRemarkRepository>();
            RemarkServiceClientMock   = new Mock <IRemarkServiceClient>();
            RemarkCacheMock           = new Mock <IRemarkCache>();
            RemarkResolvedHandler     = new RemarkResolvedHandler(Handler,
                                                                  RemarkRepositoryMock.Object,
                                                                  GroupRemarkRepositoryMock.Object,
                                                                  RemarkServiceClientMock.Object,
                                                                  RemarkCacheMock.Object);

            User = new User
            {
                UserId = UserId,
                Name   = "TestUser"
            };
            Event  = new RemarkResolved(Guid.NewGuid(), Resource.Create("test", "test"), UserId, RemarkId);
            Author = new RemarkUser
            {
                UserId = UserId,
                Name   = "TestUser"
            };
            Category = new RemarkCategory
            {
                Id   = Guid.NewGuid(),
                Name = "Test"
            };
            Location = new Location
            {
                Address     = "address",
                Coordinates = new[] { 1.0, 1.0 },
                Type        = "point"
            };
            Remark = new Remark
            {
                Id          = RemarkId,
                Author      = Author,
                Category    = Category,
                CreatedAt   = CreatedAt,
                Description = "test",
                Location    = Location,
                Photos      = new List <File>()
            };
            var resolvedRemark = new Remark
            {
                Id          = RemarkId,
                Author      = Author,
                Category    = Category,
                CreatedAt   = CreatedAt,
                Description = "test",
                Location    = Location,
                State       = new RemarkState
                {
                    State = "resolved",
                    User  = new RemarkUser
                    {
                        UserId = UserId,
                    }
                },
                Photos = new List <File>()
            };

            RemarkServiceClientMock
            .Setup(x => x.GetAsync <Remark>(RemarkId))
            .ReturnsAsync(resolvedRemark);
            RemarkRepositoryMock.Setup(x => x.GetByIdAsync(Moq.It.IsAny <Guid>()))
            .ReturnsAsync(Remark);
        }
Example #2
0
 public async Task HandleAsync(RemarkResolved @event)
 => await CompleteForAuthenticatedUserAsync(@event);