public async Task Should_Get_Signal_By_Name_And_Tag()
        {
            // Arrange
            _context.Signals.Add(new Signal
            {
                Id              = 1,
                ResourceId      = _resourceId,
                Name            = Name,
                Value           = Value,
                ValueType       = Value.GetSignalValueType(),
                IsBaseType      = Value.IsBaseType(),
                Tags            = Tags,
                DateCreated     = DateTime.Now,
                DateLastUpdated = DateTime.Now
            });
            _context.SaveChanges();

            var request = new GetSignalByNameAndTagRequest
            {
                Name = Name,
                Tag  = "Test"
            };

            // Act
            var result = await _sut.Handle(request, CancellationToken.None).ConfigureAwait(false);

            // Assert
            result.ShouldNotBeNull();
            result.ResourceId.ShouldBe(_resourceId);
            result.Name.ShouldBe(Name);
            result.Value.ShouldBe(Value);
        }
Example #2
0
        public GetFeatureFlagByResourceIdRequestHandlerTests()
        {
            var dbOptions = new DbContextOptionsBuilder <SemaphoreContext>()
                            .UseInMemoryDatabase(Guid.NewGuid().ToString())
                            .Options;

            _context = new SemaphoreContext(dbOptions);

            var feature = new Feature
            {
                ResourceId = _resourceId,
                Name       = Name
            };

            for (var i = 0; i < SignalsCount; i++)
            {
                feature.Signals.Add(new Signal
                {
                    Value = (i % 2 == 0).ToString(),
                    Tags  = i.ToString()
                });
            }

            _context.Features.Add(feature);
            _context.SaveChanges();

            _sut = new GetFeatureFlagByResourceIdRequestHandler(_context);
        }
Example #3
0
        public GetSettingRequestHandlerTests()
        {
            var dbOptions = new DbContextOptionsBuilder <SemaphoreContext>()
                            .UseInMemoryDatabase(Guid.NewGuid().ToString())
                            .Options;

            _context = new SemaphoreContext(dbOptions);
            _context.Add(new Setting
            {
                Name  = Name,
                Value = Value
            });
            _context.SaveChanges();

            _sut = new GetSettingRequestHandler(_context);
        }
Example #4
0
        public GetSignalByNameRequestHandlerTests()
        {
            var dbOptions = new DbContextOptionsBuilder <SemaphoreContext>()
                            .UseInMemoryDatabase(Guid.NewGuid().ToString())
                            .Options;

            _context = new SemaphoreContext(dbOptions);

            _context.Signals.Add(new Signal
            {
                Id              = 1,
                ResourceId      = _resourceId,
                Name            = Name,
                Value           = Value,
                ValueType       = Value.GetSignalValueType(),
                IsBaseType      = Value.IsBaseType(),
                DateCreated     = DateTime.Now,
                DateLastUpdated = DateTime.Now
            });
            _context.SaveChanges();

            _sut = new GetSignalByNameRequestHandler(_context, _mediatorMock.Object);
        }
Example #5
0
        public GetFeatureFlagByNameAndTagRequestHandlerTests()
        {
            var dbOptions = new DbContextOptionsBuilder <SemaphoreContext>()
                            .UseInMemoryDatabase(Guid.NewGuid().ToString())
                            .Options;

            _context = new SemaphoreContext(dbOptions);
            _context.Features.Add(new Feature
            {
                ResourceId = _resourceId,
                Name       = Name,
                Signals    = new List <Signal>
                {
                    new Signal
                    {
                        Tags  = $"Tag1,Tag2,Tag3,{Tag}",
                        Value = Value.ToString()
                    }
                }
            });
            _context.SaveChanges();

            _sut = new GetFeatureFlagByNameAndTagRequestHandler(_context);
        }