public void StartLocationActivity_GivenCorrectData_ExpectCorrectCalls() { Visitor visitor = new Visitor(); StandDto standDto = new StandDto(); visitor.TargetLocation = standDto; string ticket = "ticket"; VisitorStandStrategy strategy = new VisitorStandStrategy(eventProducerMock.Object, standClientMock.Object); standClientMock.Setup(client => client.OrderDinner(It.IsAny <Guid>(), It.IsAny <List <string> >())) .Returns(ticket); standClientMock.Setup(client => client.GetStand(It.IsAny <Guid>())).Returns(standDto); strategy.StartLocationActivity(visitor); var eventPayload = new Dictionary <string, string> { { "Visitor", visitor.Guid.ToString() }, { "Ticket", ticket } }; Event producedEvent = new Event(EventType.WaitingForOrder, EventSource.Visitor, eventPayload); eventProducerMock.Verify(producer => producer.Produce(It.Is <Event>(a => a.Equals(producedEvent))), Times.Once); }
public void PickStandProducts_GivenStandWithDrinks_ExpectDrink() { var meals = new List <string>(); var drinks = new List <string>() { "Product 1", "Product 2" }; Visitor visitor = new Visitor(); StandDto standDto = new StandDto(Guid.NewGuid(), "Stand", new Coordinate(), meals, drinks); List <string> products = visitor.PickStandProducts(standDto); bool inMeals = false; bool inDrinks = false; foreach (var product in products) { if (standDto.Drinks.Contains(product)) { inDrinks = true; } else if (standDto.Meals.Contains(product)) { inMeals = true; } } Assert.Single(products); Assert.True(inDrinks); Assert.False(inMeals); }
public void Nuevo(StandDto standDto) { var stand = Mapper.Map <StandDto, Stand>(standDto); //repositorioCliente.Agregar(cliente); _contexto.StandRepository.Add(stand); _contexto.Commit(); }
public void PickStandProducts_GivenStandWithoutDrinks_ExpectEmptyList() { var meals = new List <string>(); var drinks = new List <string>(); Visitor visitor = new Visitor(); StandDto standDto = new StandDto(Guid.NewGuid(), "Stand", new Coordinate(), meals, drinks); List <string> products = visitor.PickStandProducts(standDto); Assert.Empty(products); }
public void SetNewLocation_GivenVisitorHasFairyTaleAsLatestLocation_ExpectRandomRequested() { Visitor visitor = new Visitor(); StandDto location = new StandDto(); location.LocationType = LocationType.FAIRYTALE; visitor.VisitedLocations.Add(DateTime.Now, location); VisitorStandStrategy strategy = new VisitorStandStrategy(eventProducerMock.Object, standClientMock.Object); strategy.SetNewLocation(visitor); standClientMock.Verify(client => client.GetRandomStand(), Times.Once); standClientMock.Verify(client => client.GetNewStandLocation(It.IsAny <Guid>(), It.IsAny <List <Guid> >()), Times.Never); }
public void StartLocationActivity(Visitor visitor) { StandDto stand = standClient.GetStand(visitor.TargetLocation.Guid); string ticket = standClient.OrderDinner(stand.Guid, visitor.PickStandProducts(stand)); visitor.DoActivity(visitor.TargetLocation); var eventPayload = new Dictionary <string, string> { { "Visitor", visitor.Guid.ToString() }, { "Ticket", ticket } }; var waitingForOrder = new Event(EventType.WaitingForOrder, EventSource.Visitor, eventPayload); eventProducer.Produce(waitingForOrder); }
public ActionResult Nuevo(StandViewModel stand) { try { if (ModelState.IsValid) { StandDto standDto = Mapper.Map <StandViewModel, StandDto>(stand); servicioStands.Nuevo(standDto); return(RedirectToAction("Index", "Campanas", new { area = "" })); } ModelState.AddModelError("", "Hubo Error en el Modelo"); return(View(stand)); } catch (Exception) { throw; } }
public void Constructors_ConstructDto_ExpectDto() { Guid guid = Guid.NewGuid(); StandDto standDto = new StandDto(guid, "name", new Coordinate(5.23, 51.22), new List <string>() { { "meal 1" }, { "meal 2" } }, new List <string>() { { "drink 1" }, { "drink 2" } }); Assert.Equal(guid, standDto.Guid); Assert.Equal("name", standDto.Name); Assert.Equal(5.23, standDto.Coordinates.Latitude); Assert.Equal(51.22, standDto.Coordinates.Longitude); Assert.Contains <string>("meal 1", standDto.Meals); Assert.Contains <string>("meal 2", standDto.Meals); Assert.Contains <string>("drink 1", standDto.Drinks); Assert.Contains <string>("drink 2", standDto.Drinks); Assert.Equal(2, standDto.Meals.Count); Assert.Equal(2, standDto.Drinks.Count); }
public void Setters_ConstructAndUseSetters_ExpectDto() { StandDto standDto = new StandDto(); standDto.Name = "name"; standDto.Coordinates = new Coordinate(5.23, 51.22); standDto.Guid = Guid.NewGuid(); standDto.Meals = new List <string>() { { "meal 1" }, { "meal 2" } }; standDto.Drinks = new List <string>() { { "drink 1" }, { "drink 2" } }; Assert.Equal("name", standDto.Name); Assert.Equal(5.23, standDto.Coordinates.Latitude); Assert.Equal(51.22, standDto.Coordinates.Longitude); Assert.Contains <string>("meal 1", standDto.Meals); Assert.Contains <string>("meal 2", standDto.Meals); Assert.Contains <string>("drink 1", standDto.Drinks); Assert.Contains <string>("drink 2", standDto.Drinks); }