Пример #1
0
        public void MapFrom_Should_CorrectlyMapFrom_Bar_To_BarViewModel()
        {
            //Arrange
            var sut = new BarViewModelMapper();

            var bar = new BarDto
            {
                Id            = Guid.NewGuid(),
                Name          = "testName",
                Info          = "testInfo",
                ImagePath     = "testPath",
                Address       = "testAddress",
                GoogleMapsURL = "testMapsLink.gg",
                Phone         = "111-333-666",
            };

            //Act
            var result = sut.MapFrom(bar);

            //Assert
            Assert.AreEqual(result.Id, bar.Id);
            Assert.AreEqual(result.Name, bar.Name);
            Assert.AreEqual(result.Info, bar.Info);
            Assert.AreEqual(result.ImagePath, bar.ImagePath);
            Assert.AreEqual(result.Address, bar.Address);
            Assert.AreEqual(result.GoogleMapsURL, bar.GoogleMapsURL);
            Assert.AreEqual(result.Phone, bar.Phone);
        }
Пример #2
0
        public async Task CreateBar(BarDto item)
        {
            var entity = _mapper.Map <BarEntity>(item);

            _context.Bars.Add(entity);
            await _context.SaveChangesAsync();
        }
Пример #3
0
        public async Task <BarDto> CreateAsync(BarDto tempBar)
        {
            if (tempBar == null)
            {
                throw new BusinessLogicException(ExceptionMessages.BarNull);
            }

            var bar = new Bar
            {
                Name          = tempBar.Name,
                Info          = tempBar.Info,
                Address       = tempBar.Address,
                GoogleMapsURL = tempBar.GoogleMapsURL,
                ImagePath     = tempBar.ImagePath,
                Phone         = tempBar.Phone
            };

            await this.context.Bars.AddAsync(bar);

            await this.context.SaveChangesAsync();

            var barDto = this.dtoMapper.MapFrom(bar);

            return(barDto);
        }
Пример #4
0
        public void Map_MapFromBarDtoToBar_CorrectType()
        {
            var barDto = new BarDto();
            var bar    = uut.Map <Bar>(barDto);

            Assert.That(bar, Is.TypeOf <Bar>());
        }
        public async Task CorrectlyRemoveCocktailsWhen_ParamsAreValid()
        {
            //Arrange
            var options            = TestUtilities.GetOptions(nameof(CorrectlyRemoveCocktailsWhen_ParamsAreValid));
            var mapperMock         = new Mock <IDtoMapper <Bar, BarDto> >();
            var searchMapperMock   = new Mock <IDtoMapper <Bar, SearchBarDto> >();
            var cocktailMapperMock = new Mock <IDtoMapper <Cocktail, CocktailDto> >();
            var testGuid           = Guid.NewGuid();
            var cocktailGuid       = Guid.NewGuid();

            var bar1 = new Bar
            {
                Id   = testGuid,
                Name = "testBar1",
            };

            var barDto1 = new BarDto
            {
                Id   = testGuid,
                Name = "testBar1",
            };

            var list = new List <string> {
                "Boza"
            };

            var cocktail = new Cocktail {
                Id = cocktailGuid, Name = "Boza"
            };
            var barCocktail = new BarCocktail {
                BarId = bar1.Id, CocktailId = cocktailGuid
            };

            mapperMock.Setup(x => x.MapFrom(It.IsAny <Bar>())).Returns(barDto1);

            using (var arrangeContext = new CWContext(options))
            {
                await arrangeContext.Bars.AddAsync(bar1);

                await arrangeContext.Cocktails.AddAsync(cocktail);

                await arrangeContext.BarCocktails.AddAsync(barCocktail);

                await arrangeContext.SaveChangesAsync();
            }

            using (var assertContext = new CWContext(options))
            {
                //Act & Assert
                var sut    = new BarService(assertContext, mapperMock.Object, searchMapperMock.Object, cocktailMapperMock.Object);
                var result = await sut.RemoveCocktailsAsync(barDto1, list);

                var barCocktailEntity = await assertContext.BarCocktails.FirstAsync();

                Assert.IsInstanceOfType(result, typeof(BarDto));
                Assert.AreEqual("testBar1", result.Name);
                Assert.AreEqual(true, barCocktailEntity.IsDeleted);
            }
        }
Пример #6
0
        public async Task ReturnCorectTypeOfInstance()
        {
            //Arrange
            var options            = TestUtilities.GetOptions(nameof(ReturnCorectTypeOfInstance));
            var mapperMock         = new Mock <IDtoMapper <Bar, BarDto> >();
            var searchMapperMock   = new Mock <IDtoMapper <Bar, SearchBarDto> >();
            var cocktailMapperMock = new Mock <IDtoMapper <Cocktail, CocktailDto> >();
            var guid = Guid.NewGuid();

            var entityDto = new BarDto
            {
                Id        = guid,
                Name      = "testBar",
                Info      = "testInfo",
                Address   = "testAddress",
                ImagePath = "testImagePath",
                Phone     = "111-333-666"
            };

            var bar = new Bar
            {
                Id        = guid,
                Name      = "testBar",
                Info      = "testInfo",
                Address   = "testAddress",
                ImagePath = "testImagePath",
                Phone     = "111-333-666"
            };

            var cocktail = new Cocktail
            {
                Id   = Guid.NewGuid(),
                Name = "testCocktail",
                Info = "testCocktailInfo",
            };

            var list = new List <string>()
            {
                "testCocktail"
            };

            using (var arrangeContext = new CWContext(options))
            {
                await arrangeContext.Bars.AddAsync(bar);

                await arrangeContext.Cocktails.AddAsync(cocktail);

                await arrangeContext.SaveChangesAsync();
            }

            using (var assertContext = new CWContext(options))
            {
                //Act & Assert
                var sut    = new BarService(assertContext, mapperMock.Object, searchMapperMock.Object, cocktailMapperMock.Object);
                var result = await sut.AddCocktailsAsync(entityDto, list);

                Assert.IsInstanceOfType(result, typeof(BarDto));
            }
        }
Пример #7
0
        public void TestNullReferenceException()
        {
            var barDto = new BarDto {
                Text = "Foo is null."
            };

            AssertEx.IsTrue(() => barDto.Foo.Baz == 5);
        }
Пример #8
0
        public void TestNullProperty()
        {
            var barDto = new BarDto {
                Text = "Foo is null."
            };

            AssertEx.IsTrue(() => barDto.Foo != null);
        }
        public void TestLargeObjectWithLargeArrayFormatting()
        {
            var bar = new BarDto {
                Text = "Oogity Boogity Boo, The Krampus comes for you.", Ints = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }
            };

            AssertEx.IsTrue(() => bar == null);
        }
Пример #10
0
        public async Task CreateBar(BarDto item)
        {
            var doc = _mapper.Map <BarDoc>(item);

            using (var session = await _client.StartSessionAsync())
            {
                await _collection.InsertOneAsync(session, doc);
            }
        }
Пример #11
0
        public async Task ThrowWhen_NobarFound()
        {
            //Arrange
            var options            = TestUtilities.GetOptions(nameof(ThrowWhen_NobarFound));
            var mapperMock         = new Mock <IDtoMapper <Bar, BarDto> >();
            var searchMapperMock   = new Mock <IDtoMapper <Bar, SearchBarDto> >();
            var cocktailMapperMock = new Mock <IDtoMapper <Cocktail, CocktailDto> >();
            var guid = Guid.NewGuid();

            var entityDto = new BarDto
            {
                Id        = Guid.NewGuid(),
                Name      = "testBar",
                Info      = "testInfo",
                Address   = "testAddress",
                ImagePath = "testImagePath",
                Phone     = "111-333-666"
            };

            var bar = new Bar
            {
                Id        = guid,
                Name      = "testBar",
                Info      = "testInfo",
                Address   = "testAddress",
                ImagePath = "testImagePath",
                Phone     = "111-333-666"
            };

            var cocktail = new Cocktail
            {
                Id   = Guid.NewGuid(),
                Name = "testCocktail",
                Info = "testCocktailInfo",
            };

            var list = new List <string>()
            {
                "testCocktail"
            };

            using (var arrangeContext = new CWContext(options))
            {
                await arrangeContext.Bars.AddAsync(bar);

                await arrangeContext.Cocktails.AddAsync(cocktail);

                await arrangeContext.SaveChangesAsync();
            }

            using (var assertContext = new CWContext(options))
            {
                //Act & Assert
                var sut = new BarService(assertContext, mapperMock.Object, searchMapperMock.Object, cocktailMapperMock.Object);
                await Assert.ThrowsExceptionAsync <BusinessLogicException>(() => sut.AddCocktailsAsync(entityDto, list));
            }
        }
Пример #12
0
        public async Task CreateBar(BarDto item)
        {
            var query = "INSERT INTO [dbo].[Bars] ([BarId], [FooId], [Name], [Active]) VALUES (@BarId, @FooId, @Name, @Active);";

            using (var connection = new SqlConnection(_connectionString))
            {
                await connection.ExecuteAsync(query, new { BarId = item.BarId, FooId = item.FooId, Name = item.Name, Active = item.Active });
            }
        }
        public void TestLargeObjectWithSmallArrayFormatting()
        {
            var bar = new BarDto {
                Text = "Oogity Boogity Boo, The Krampus comes for you.", Foo = new FooDto {
                    Bar = "hashtag yolo swag", Baz = 1
                }, Ints = new[] { 1, 2, 3 }
            };

            AssertEx.IsTrue(() => bar == null);
        }
Пример #14
0
        public async Task ReturnCorrectTypeOfInstance()
        {
            //Arrange
            var options            = TestUtilities.GetOptions(nameof(ReturnCorrectTypeOfInstance));
            var mapperMock         = new Mock <IDtoMapper <Bar, BarDto> >();
            var searchMapperMock   = new Mock <IDtoMapper <Bar, SearchBarDto> >();
            var cocktailMapperMock = new Mock <IDtoMapper <Cocktail, CocktailDto> >();
            var guid = Guid.NewGuid();

            var entity = new Bar
            {
                Id        = guid,
                Name      = "testBar",
                Info      = "testInfo",
                Address   = "testAddress",
                ImagePath = "testImagePath",
                Phone     = "111-333-666"
            };

            var dtoEntity = new BarDto
            {
                Id        = guid,
                Name      = "testBar",
                Info      = "testInfo",
                Address   = "testAddress",
                ImagePath = "testImagePath",
                Phone     = "111-333-666"
            };

            mapperMock.Setup(x => x.MapFrom(It.IsAny <Bar>())).Returns(dtoEntity);

            using (var actContext = new CWContext(options))
            {
                //Act
                await actContext.Bars.AddAsync(entity);

                await actContext.SaveChangesAsync();
            }
            using (var assertContext = new CWContext(options))
            {
                //Assert
                var sut    = new BarService(assertContext, mapperMock.Object, searchMapperMock.Object, cocktailMapperMock.Object);
                var result = await sut.DeleteAsync(guid);

                Assert.IsInstanceOfType(result, typeof(BarDto));
                Assert.AreEqual(dtoEntity.Name, result.Name);
                Assert.AreEqual(dtoEntity.Info, result.Info);
                Assert.AreEqual(dtoEntity.Address, result.Address);
                Assert.AreEqual(dtoEntity.ImagePath, result.ImagePath);
                Assert.AreEqual(dtoEntity.Phone, result.Phone);
                Assert.AreEqual(dtoEntity.Id, result.Id);
            }
        }
        public async Task ThrowWhen_IngredientNotFound()
        {
            //Arrange
            var options            = TestUtilities.GetOptions(nameof(ThrowWhen_IngredientNotFound));
            var mapperMock         = new Mock <IDtoMapper <Bar, BarDto> >();
            var searchMapperMock   = new Mock <IDtoMapper <Bar, SearchBarDto> >();
            var cocktailMapperMock = new Mock <IDtoMapper <Cocktail, CocktailDto> >();
            var testGuid           = Guid.NewGuid();
            var cocktailGuid       = Guid.NewGuid();

            var bar1 = new Bar
            {
                Id   = testGuid,
                Name = "testBar1",
            };

            var barDto1 = new BarDto
            {
                Id   = testGuid,
                Name = "testBar1",
            };

            var list = new List <string> {
                "Banica"
            };

            var cocktail = new Cocktail {
                Id = cocktailGuid, Name = "Boza"
            };
            var barCocktail = new BarCocktail {
                BarId = bar1.Id, CocktailId = cocktailGuid
            };

            mapperMock.Setup(x => x.MapFrom(It.IsAny <Bar>())).Returns(barDto1);

            using (var arrangeContext = new CWContext(options))
            {
                await arrangeContext.Bars.AddAsync(bar1);

                await arrangeContext.Cocktails.AddAsync(cocktail);

                await arrangeContext.BarCocktails.AddAsync(barCocktail);

                await arrangeContext.SaveChangesAsync();
            }

            using (var assertContext = new CWContext(options))
            {
                //Act & Assert
                var sut = new BarService(assertContext, mapperMock.Object, searchMapperMock.Object, cocktailMapperMock.Object);
                await Assert.ThrowsExceptionAsync <BusinessLogicException>(() => sut.RemoveCocktailsAsync(barDto1, list));
            }
        }
Пример #16
0
        public static Feature ParseBarToFeature(BarDto bar)
        {
            var geometry   = new Point(new Position(bar.Lat, bar.Lon));
            var properties = new Dictionary <string, dynamic>
            {
                { "Id", bar.Id.ToString() },
                { "Name", bar.Name == null? "": bar.Name.ToString() },
                { "BarType", bar.BarType }
            };

            return(new Feature(geometry, properties));
        }
Пример #17
0
 public IActionResult UpdateBar([FromBody] BarDto barDto)
 {
     try
     {
         var bar = _mapper.Map <Bar>(barDto);
         _unitOfWork.BarRepository.Edit(bar);
         _unitOfWork.Complete();
         return(Created($"api/bars/{barDto.BarName}", barDto));
     }
     catch (Exception e)
     {
         return(BadRequest());
     }
 }
Пример #18
0
        public async Task <BarDto> AddCocktailsAsync(BarDto barDto, List <string> selectedCocktails)
        {
            var bar = await this.context.Bars
                      .Where(b => b.IsDeleted == false)
                      .FirstOrDefaultAsync(b => b.Id == barDto.Id);

            if (bar == null)
            {
                throw new BusinessLogicException(ExceptionMessages.BarNull);
            }

            if (!selectedCocktails.Any())
            {
                throw new BusinessLogicException(ExceptionMessages.CocktailNull);
            }

            foreach (var item in selectedCocktails)
            {
                var cocktail = await this.context.Cocktails
                               .Where(c => c.IsDeleted == false)
                               .FirstOrDefaultAsync(c => c.Name == item) ?? throw new BusinessLogicException(ExceptionMessages.CocktailNull);

                var barCocktail = await this.context.BarCocktails
                                  .Where(c => c.CocktailId == cocktail.Id && c.BarId == bar.Id)
                                  .FirstOrDefaultAsync();

                if (barCocktail == null)
                {
                    barCocktail = new BarCocktail
                    {
                        Bar      = bar,
                        Cocktail = cocktail,
                    };
                    await this.context.BarCocktails.AddAsync(barCocktail);

                    bar.BarCocktails.Add(barCocktail);
                    cocktail.BarCocktails.Add(barCocktail);
                }
                else
                {
                    barCocktail.IsDeleted = false;
                    barCocktail.DeletedOn = DateTime.MinValue;
                }
            }

            await this.context.SaveChangesAsync();

            return(barDto);
        }
Пример #19
0
        internal void GivenMapFromBarDtoToBarWhenSourceIsNotNullThenMapsData()
        {
            // Arrange
            var barDto = new BarDto
            {
                Value = "bar"
            };

            // Act
            var bar = mapper.Map <Bar>(barDto);

            // Assert
            bar.Should().NotBeNull().And.BeOfType <Bar>();
            bar.Value.Should().Be(barDto.Value);
        }
Пример #20
0
 public IActionResult AddBar([FromBody] BarDto dtoBar)
 {
     try
     {
         _unitOfWork.BarRepository.Add(_mapper.Map <Bar>(dtoBar));
         _unitOfWork.Complete();
         return(Created($"api/bars/{dtoBar.BarName}", dtoBar));
     }
     catch (Exception e)
     {
         if (e.InnerException is SqlException exception && exception.Number == 2627)
         {
             return(BadRequest("Duplicate Key"));
         }
         return(BadRequest());
     }
 }
Пример #21
0
        public void TestLargeObjectFormatting()
        {
            var bar = new BarDto {
                Text = "Oogity Boogity Boo, The Krampus comes for you.", Foo = new FooDto {
                    Bar = "hashtag yolo swag", Baz = 1
                }
            };

            AssertThrowsAssertion(() => bar == null, @"Expected:
	bar == null

Actual:
	bar = {
		""text"": ""Oogity Boogity Boo, The Krampus comes for you."",
		""foo"": { ""bar"": ""hashtag yolo swag"", ""baz"": 1 }
	}"    );
        }
Пример #22
0
    public void JsonConverter_Test()
    {
        var fooDto = new FooDto
        {
            Name    = "foo-dto",
            BarDtos = new List <BarDto>()
        };

        fooDto.SetProperty("foo", "foo-value");

        var barDto = new BarDto
        {
            Name = "bar-dto"
        };

        barDto.SetProperty("bar", "bar-value");
        fooDto.BarDtos.Add(barDto);

        var json = _jsonSerializer.Serialize(fooDto);

        fooDto = _jsonSerializer.Deserialize <FooDto>(json);
        fooDto.ShouldNotBeNull();
        fooDto.Name.ShouldBe("foo-dto");
        fooDto.GetProperty("foo").ShouldBe("foo-value");

        fooDto.BarDtos.Count.ShouldBe(1);
        fooDto.BarDtos.First().Name.ShouldBe("bar-dto");
        fooDto.BarDtos.First().GetProperty("bar").ShouldBe("bar-value");

        fooDto.Name = "new-foo-dto";
        fooDto.SetProperty("foo", "new-foo-value");
        fooDto.BarDtos.First().Name = "new-bar-dto";
        fooDto.BarDtos.First().SetProperty("bar", "new-bar-value");

        json = _jsonSerializer.Serialize(fooDto);

        fooDto = _jsonSerializer.Deserialize <FooDto>(json);
        fooDto.ShouldNotBeNull();
        fooDto.Name.ShouldBe("new-foo-dto");
        fooDto.GetProperty("foo").ShouldBe("new-foo-value");

        fooDto.BarDtos.Count.ShouldBe(1);
        fooDto.BarDtos.First().Name.ShouldBe("new-bar-dto");
        fooDto.BarDtos.First().GetProperty("bar").ShouldBe("new-bar-value");
    }
Пример #23
0
        public void AddBar_NonValidModelReceived_ReturnsBadRequest()
        {
            // Arrange
            mockUnitOfWork.BarRepository
            .When(x => x.Add(Arg.Any <Bar>()))
            .Do(x => throw new Exception());

            var badBarDto = new BarDto()
            {
                BarName = "This Bar Only has a name which isn't enough",
            };

            // Act
            var result = uut.AddBar(badBarDto);

            // Assert
            Assert.That(result, Is.TypeOf <BadRequestResult>());
        }
Пример #24
0
        public async Task ReturnCorrectTypeOfEntity()
        {
            //Arrange
            var options            = TestUtilities.GetOptions(nameof(ReturnCorrectTypeOfEntity));
            var mapperMock         = new Mock <IDtoMapper <Bar, BarDto> >();
            var searchMapperMock   = new Mock <IDtoMapper <Bar, SearchBarDto> >();
            var cocktailMapperMock = new Mock <IDtoMapper <Cocktail, CocktailDto> >();
            var testGuid           = Guid.NewGuid();

            var bar = new Bar
            {
                Id      = testGuid,
                Name    = "testBar",
                Info    = "testInfo",
                Address = "testAddress",
                Phone   = "111-333-666",
            };

            var dtoEntity = new BarDto
            {
                Id      = testGuid,
                Name    = "testBar",
                Info    = "testInfo",
                Address = "testAddress",
                Phone   = "111-333-666"
            };

            mapperMock.Setup(x => x.MapFrom(It.IsAny <Bar>())).Returns(dtoEntity);

            using (var arrangeContext = new CWContext(options))
            {
                await arrangeContext.Bars.AddAsync(bar);

                await arrangeContext.SaveChangesAsync();
            }

            using (var assertContext = new CWContext(options))
            {
                var sut    = new BarService(assertContext, mapperMock.Object, searchMapperMock.Object, cocktailMapperMock.Object);
                var result = await sut.EditAsync(testGuid, "newTestName", "newTestInfo", "newTestAddress", "111-333-6667");

                Assert.IsInstanceOfType(result, typeof(BarDto));
            }
        }
Пример #25
0
        public void TestLargeObjectWithLargeArrayFormatting()
        {
            var bar = new BarDto {
                Text = "Oogity Boogity Boo, The Krampus comes for you.", Ints = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }
            };

            AssertThrowsAssertion(() => bar == null, @"Expected:
	bar == null

Actual:
	bar = {
		""text"": ""Oogity Boogity Boo, The Krampus comes for you."",
		""ints"": [
			1,
			2,
			3,
			4,
			5,
			6,
			7,
			8,
			9,
			10,
			11,
			12,
			13,
			14,
			15,
			16,
			17,
			18,
			19,
			20,
			21,
			22,
			23,
			24,
			25,
			26
		]
	}"    );
        }
Пример #26
0
        public async Task ReturnCorrectDtoWhen_ParamsAreValid()
        {
            //Arrange
            var options            = TestUtilities.GetOptions(nameof(ReturnCorrectDtoWhen_ParamsAreValid));
            var mapperMock         = new Mock <IDtoMapper <Bar, BarDto> >();
            var searchMapperMock   = new Mock <IDtoMapper <Bar, SearchBarDto> >();
            var cocktailMapperMock = new Mock <IDtoMapper <Cocktail, CocktailDto> >();
            var testGuid           = Guid.NewGuid();

            var bar1 = new Bar
            {
                Id   = testGuid,
                Name = "testBar1",
            };

            var barDto1 = new BarDto
            {
                Id   = testGuid,
                Name = "testBar1",
            };

            mapperMock.Setup(x => x.MapFrom(It.IsAny <Bar>())).Returns(barDto1);

            using (var arrangeContext = new CWContext(options))
            {
                await arrangeContext.Bars.AddAsync(bar1);

                await arrangeContext.SaveChangesAsync();
            }

            using (var assertContext = new CWContext(options))
            {
                //Act & Assert
                var sut    = new BarService(assertContext, mapperMock.Object, searchMapperMock.Object, cocktailMapperMock.Object);
                var result = await sut.GetBarCocktailsAsync(testGuid);

                Assert.IsInstanceOfType(result, typeof(BarDto));
                Assert.AreEqual("testBar1", result.Name);
            }
        }
Пример #27
0
        public void MapFrom_Should_ReturnCorrectInstanceOf_BarViewModel()
        {
            //Arrange
            var sut = new BarViewModelMapper();

            var bar = new BarDto
            {
                Id            = Guid.NewGuid(),
                Name          = "testName",
                Info          = "testInfo",
                ImagePath     = "testPath",
                Address       = "testAddress",
                GoogleMapsURL = "testMapsLink.gg",
                Phone         = "111-333-666",
            };

            //Act
            var result = sut.MapFrom(bar);

            //Assert
            Assert.IsInstanceOfType(result, typeof(BarViewModel));
        }
        public async Task CorrectlyCreateBar()
        {
            //Arrange
            var options            = TestUtilities.GetOptions(nameof(CorrectlyCreateBar));
            var mapperMock         = new Mock <IDtoMapper <Bar, BarDto> >();
            var searchMapperMock   = new Mock <IDtoMapper <Bar, SearchBarDto> >();
            var cocktailMapperMock = new Mock <IDtoMapper <Cocktail, CocktailDto> >();

            var entityDto = new BarDto
            {
                Id        = Guid.NewGuid(),
                Name      = "testBar",
                Info      = "testInfo",
                Address   = "testAddress",
                ImagePath = "testImagePath",
                Phone     = "111-333-666"
            };

            mapperMock.Setup(x => x.MapFrom(It.IsAny <Bar>())).Returns(entityDto);

            using (var assertContext = new CWContext(options))
            {
                //Act & Assert
                var sut    = new BarService(assertContext, mapperMock.Object, searchMapperMock.Object, cocktailMapperMock.Object);
                var result = await sut.CreateAsync(entityDto);

                Assert.IsInstanceOfType(result, typeof(BarDto));
                Assert.AreEqual("testBar", result.Name);
                Assert.AreEqual("testInfo", result.Info);
                Assert.AreEqual("testAddress", result.Address);
                Assert.AreEqual("testImagePath", result.ImagePath);
                Assert.AreEqual("111-333-666", result.Phone);
                Assert.AreEqual(entityDto.Name, result.Name);
                Assert.AreEqual(entityDto.Info, result.Info);
                Assert.AreEqual(entityDto.Address, result.Address);
                Assert.AreEqual(entityDto.ImagePath, result.ImagePath);
                Assert.AreEqual(entityDto.Phone, result.Phone);
            }
        }
Пример #29
0
        public void MapFrom_Should_CorrectlyMapRatingFrom_BarDto_To_BarViewModel_WhenCollectionIsNotEmpty()
        {
            //Arrange
            var sut = new BarViewModelMapper();

            var bar = new BarDto
            {
                Id            = Guid.NewGuid(),
                Name          = "testName",
                Info          = "testInfo",
                ImagePath     = "testPath",
                Address       = "testAddress",
                GoogleMapsURL = "testMapsLink.gg",
                Phone         = "111-333-666",
                AverageRating = 4.55,
            };

            //Act
            var result = sut.MapFrom(bar);

            //Assert
            Assert.AreEqual(result.AverageRating, 4.55);
        }
Пример #30
0
        public async Task <IActionResult> Create([FromBody] BarDto item)
        {
            await _manager.CreateBar(item);

            return(Ok());
        }