Esempio n. 1
0
        public async Task When_Create_MissingTimestamp()
        {
            var locationLogEntryDto = new LocationLogEntryQueryDto()
            {
                LocationId = _mockContext.Object.LocationLogEntries.Single(x => x.Id == new Guid("44E0C497-3A2C-4A89-99BD-F7B14C1A9187")).LocationId,
                LogEntry   = "Create Log Entry"
            };

            var commandResult = await _facade.Create(locationLogEntryDto);

            Assert.That(commandResult.StatusCode, Is.EqualTo(FacadeStatusCode.BadRequest));
            Assert.That(commandResult.ErrorCodes.Count, Is.EqualTo(1));
            Assert.That(commandResult.ErrorCodes[0].Code, Is.EqualTo("FFERR-201"));
        }
Esempio n. 2
0
        public async Task When_Create_BadLocation()
        {
            var locationLogEntryDto = new LocationLogEntryQueryDto()
            {
                LocationId = Guid.NewGuid(),
                LogEntry   = "Create Log Entry",
                TimeStamp  = DateTimeOffset.UtcNow
            };

            var commandResult = await _facade.Create(locationLogEntryDto);

            Assert.That(commandResult.StatusCode, Is.EqualTo(FacadeStatusCode.BadRequest));
            Assert.That(commandResult.ErrorCodes.Count, Is.EqualTo(1));
            Assert.That(commandResult.ErrorCodes[0].Code, Is.EqualTo("FFERR-209"));
        }
Esempio n. 3
0
        public async Task When_Create_BadToken()
        {
            Thread.CurrentPrincipal = new ClaimsPrincipal(new ClaimsIdentity(new List <Claim>()));

            var locationLogEntryDto = new LocationLogEntryQueryDto()
            {
                LocationId = _mockContext.Object.LocationLogEntries.Single(x => x.Id == new Guid("44E0C497-3A2C-4A89-99BD-F7B14C1A9187")).Id,
                LogEntry   = "Create Log Entry"
            };

            var commandResult = await _facade.Create(locationLogEntryDto);

            Assert.That(commandResult.StatusCode, Is.EqualTo(FacadeStatusCode.Unauthorized));
            Assert.That(commandResult.ErrorCodes.Count, Is.EqualTo(1));
            Assert.That(commandResult.ErrorCodes[0].Code, Is.EqualTo("FFERR-304"));
        }
Esempio n. 4
0
        public async Task When_Create_Succeeds()
        {
            var locationLogEntryDto = new LocationLogEntryQueryDto()
            {
                LocationId = _mockContext.Object.LocationLogEntries.Single(x => x.Id == new Guid("44E0C497-3A2C-4A89-99BD-F7B14C1A9187")).LocationId,
                LogEntry   = "Create Log Entry",
                TimeStamp  = DateTimeOffset.UtcNow
            };

            var commandResult = await _facade.Create(locationLogEntryDto);

            Assert.That(commandResult.StatusCode, Is.EqualTo(FacadeStatusCode.Created));
            Assert.That(commandResult.Entity.LocationId, Is.EqualTo(_mockContext.Object.LocationLogEntries.Single(x => x.Id == new Guid("44E0C497-3A2C-4A89-99BD-F7B14C1A9187")).LocationId));
            Assert.That(commandResult.Entity.LogEntry, Is.EqualTo("Create Log Entry"));
            Assert.That(commandResult.Entity.CreatedById, Is.EqualTo(_userId));
            Assert.That((DateTime.Now - commandResult.Entity.CreatedOn).Seconds, Is.LessThanOrEqualTo(10));
            Assert.That(commandResult.Entity.ModifiedById, Is.EqualTo(_userId));
            Assert.That((DateTime.Now - commandResult.Entity.ModifiedOn).Seconds, Is.LessThanOrEqualTo(10));
        }