示例#1
0
        public void CanGetASynonymGroupEntity()
        {
            var synonymGroup = EntityHelpers.CreateSynonymGroup();

            DatabaseContext.Add(synonymGroup);
            DatabaseContext.SaveChanges();
            var result = DatabaseContext.SynonymGroups.FirstOrDefault(x => x.Id == synonymGroup.Id);

            result.Should().BeEquivalentTo(synonymGroup);
        }
示例#2
0
        public void GivenAnIdAMatchingSynonymGroupGetsDeleted()
        {
            var synonymGroup = EntityHelpers.CreateSynonymGroup();

            DatabaseContext.Add(synonymGroup);
            DatabaseContext.SaveChanges();
            _classUnderTest.DeleteSynonymGroup(synonymGroup.Id);
            var expectedResult = DatabaseContext.SynonymGroups.Find(synonymGroup.Id);

            expectedResult.Should().BeNull();
        }
示例#3
0
        public void GivenSynonymGroupDomainObjectSynonymGroupGetsCreated()
        {
            var synonymGroup   = EntityHelpers.CreateSynonymGroup();
            var gatewayResult  = _classUnderTest.CreateSynonymGroup(synonymGroup);
            var expectedResult = DatabaseContext.SynonymGroups.Where(x => x.Name == synonymGroup.Name).FirstOrDefault();

            gatewayResult.Should().NotBeNull();
            gatewayResult.Should().BeEquivalentTo(expectedResult, options =>
            {
                options.Excluding(ex => ex.SynonymWords);
                return(options);
            });
        }
示例#4
0
        public void GivenAnIdAMatchingSynonymGroupGetsReturned()
        {
            var synonymGroup = EntityHelpers.CreateSynonymGroup();

            DatabaseContext.Add(synonymGroup);
            DatabaseContext.SaveChanges();
            var gatewayResult  = _classUnderTest.GetSynonymGroup(synonymGroup.Id);
            var expectedResult = DatabaseContext.SynonymGroups.Find(synonymGroup.Id);

            gatewayResult.Should().NotBeNull();
            gatewayResult.Should().BeEquivalentTo(expectedResult, options =>
            {
                options.Excluding(ex => ex.SynonymWords);
                return(options);
            });
        }
示例#5
0
        public void GivenAnSynonymGroupAMatchingSynonymGroupGetsUpdated()
        {
            var synonymGroup = EntityHelpers.CreateSynonymGroup();

            DatabaseContext.Add(synonymGroup);
            DatabaseContext.SaveChanges();
            var synonymGroupDomain = _mapper.ToDomain(synonymGroup);

            synonymGroupDomain.Name = Randomm.Text();
            _classUnderTest.PatchSynonymGroup(synonymGroupDomain);
            var expectedResult = DatabaseContext.SynonymGroups.Find(synonymGroup.Id);

            expectedResult.Should().BeEquivalentTo(synonymGroupDomain, options =>
            {
                options.Excluding(ex => ex.SynonymWords);
                return(options);
            });
        }
示例#6
0
        public void GivenSearchParametersMatchingSynonymGroupsGetReturned()
        {
            var synonymGroup = EntityHelpers.CreateSynonymGroup();

            DatabaseContext.AddRange(synonymGroup);
            DatabaseContext.SaveChanges();
            var searchParams = new SynonymGroupSearchRequest();
            var sgToFind     = synonymGroup;

            searchParams.Search    = sgToFind.Name;
            searchParams.Sort      = "Name";
            searchParams.Direction = SortDirection.Asc.ToString();
            var gatewayResult = _classUnderTest.SearchSynonymGroups(searchParams);

            gatewayResult.Should().NotBeNull();
            gatewayResult.First().Should().BeEquivalentTo(sgToFind, options =>
            {
                options.Excluding(ex => ex.SynonymWords);
                return(options);
            });
        }