Exemplo n.º 1
0
 public CarSetEvent(CarId carId, string make, string model, string no, CarColor color = CarColor.White)
 {
     CarId = carId;
     Make  = make;
     Model = model;
     No    = no;
     Color = color;
 }
Exemplo n.º 2
0
        public EventStoreTests(DependencyInjectionFixture diFixture)
        {
            var tables = diFixture.Container.GetRequiredService <IDictionary <string, CloudTable> >();

            _aggregateId      = new CarId(Guid.NewGuid());
            _container        = diFixture.Container;
            _eventStoreTable  = tables[ContainerName.EventStore];
            _azureTableHelper = new AzureTableHelper <DynamicTableEntity>(4);
        }
Exemplo n.º 3
0
        public override string ToString()
        {
            var builder = new System.Text.StringBuilder();

            builder.AppendFormat("{0} {{", nameof(ChatMessage)).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(CarId), CarId.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(Message), Message.ToString()).AppendLine();
            builder.AppendFormat("}}").AppendLine();
            return(builder.ToString());
        }
Exemplo n.º 4
0
 private void MapViewModelsToCommands()
 {
     this.CreateMap <AddCarViewModel, AddCarCommand>()
     .ConstructUsing(source => new AddCarCommand(CarId.NewComb(), source.Name, source.BatteryCapacity));
     this.CreateMap <EditCarViewModel, EditCarCommand>()
     .ConstructUsing(source =>
                     new EditCarCommand(CarId.With(Guid.Parse(source.Id)), source.Name, source.BatteryCapacity));
     this.CreateMap <DeleteCarViewModel, DeleteCarCommand>()
     .ConstructUsing(source => new DeleteCarCommand(CarId.With(Guid.Parse(source.Id))));
 }
Exemplo n.º 5
0
 public override int GetHashCode()
 {
     unchecked {
         var hashCode = Name?.GetHashCode() ?? 0;
         hashCode = (hashCode * 397) ^ IsPlayer.GetHashCode();
         hashCode = (hashCode * 397) ^ (CarId?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (SkinId?.GetHashCode() ?? 0);
         return(hashCode);
     }
 }
Exemplo n.º 6
0
        public RepositoryTests(DependencyInjectionFixture diFixture)
        {
            var tables = diFixture.Container.GetRequiredService <IDictionary <string, CloudTable> >();

            // These variables are reset per unit test
            _carId            = new CarId(Guid.NewGuid());
            _azureTableHelper = new AzureTableHelper <DynamicTableEntity>();
            _repository       = diFixture.Container.GetRequiredService <IAggregateRepository <Car, CarId> >();
            _eventStoreTable  = tables[ContainerName.EventStore];
        }
Exemplo n.º 7
0
        public void Should_be_same()
        {
            var newId = "123";

            var first = new CarId(newId);

            var second = new CarId(newId);

            first.Should().BeEquivalentTo(second);

            (first == second).Should().BeTrue();
        }
Exemplo n.º 8
0
 public override int GetHashCode()
 {
     unchecked {
         var hashCode = Name?.GetHashCode() ?? 0;
         hashCode = (hashCode * 397) ^ (Team?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (CarId?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (CarSkinId?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ IsConnected.GetHashCode();
         hashCode = (hashCode * 397) ^ IsBookedForPlayer.GetHashCode();
         return(hashCode);
     }
 }
Exemplo n.º 9
0
        public static void SpawnVehicle(CarId carId)
        {
            var position = _my.Player.Character.Position.Around(5);

            Log.Debug("position read: " + position.ToString());

            var car = World.CreateVehicle(carId, position);

            Log.Debug("position car: " + car.Position.ToString());
            car.LockStatus = LockDoorTyp.Unlocked;
            car.NoLongerNeeded();
        }
Exemplo n.º 10
0
        public void Should_throw_an_exception_when_aggregate_is_not_found()
        {
            // Arrange
            var eventStore = _container.GetRequiredService <IEventStore>();
            var id         = new CarId(_aggregateId.Id);

            // Act
            Func <Task> func = async() => await eventStore.GetEventsForAggregate(id);

            // Assert
            func.Should().Throw <AggregateNotFoundException>();
        }
Exemplo n.º 11
0
        public override string ToString()
        {
            var builder = new System.Text.StringBuilder();

            builder.AppendFormat("{0} {{", nameof(LeaderboardEntry)).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(CarId), CarId.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(LapTime), LapTime.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(Laps), Laps.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(HasFinished), HasFinished.ToString()).AppendLine();
            builder.AppendFormat("}}").AppendLine();
            return(builder.ToString());
        }
Exemplo n.º 12
0
        public override string ToString()
        {
            var builder = new System.Text.StringBuilder();

            builder.AppendFormat("{0} {{", nameof(ConnectionInfo)).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(DriverName), DriverName.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(DriverGuid), DriverGuid.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(CarId), CarId.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(CarModel), CarModel.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(CarSkin), CarSkin.ToString()).AppendLine();
            builder.AppendFormat("}}").AppendLine();
            return(builder.ToString());
        }
Exemplo n.º 13
0
        public override string ToString()
        {
            var builder = new System.Text.StringBuilder();

            builder.AppendFormat("{0} {{", nameof(CarUpdateInfo)).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(CarId), CarId.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(Position), Position.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(Velocity), Velocity.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(Gear), Gear.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(EngineRpm), EngineRpm.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(SplinePos), SplinePos.ToString()).AppendLine();
            builder.AppendFormat("}}").AppendLine();
            return(builder.ToString());
        }
Exemplo n.º 14
0
        public override string ToString()
        {
            var builder = new System.Text.StringBuilder();

            builder.AppendFormat("{0} {{", nameof(ClientEventInfo)).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(CollisionType), CollisionType.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(CarId), CarId.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(OtherCarId), OtherCarId.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(Speed), Speed.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(WorldPosition), WorldPosition.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(RelativePosition), RelativePosition.ToString()).AppendLine();
            builder.AppendFormat("}}").AppendLine();
            return(builder.ToString());
        }
Exemplo n.º 15
0
        public async Task <IActionResult> PatchCar([FromRoute] Guid id, [FromBody] CarInputModel model)
        {
            var aggregateId = CarId.With(id);

            var command = new ChangeCarNameCommand(aggregateId, model.Name);

            var executionResult = await _aggregateManager.Ask <ExecutionResult>(command);

            if (executionResult.IsSuccess)
            {
                return(Accepted(new { Id = aggregateId.GetGuid() }));
            }

            return(BadRequest(executionResult.ToString()));
        }
Exemplo n.º 16
0
        public override string ToString()
        {
            var builder = new System.Text.StringBuilder();

            builder.AppendFormat("{0} {{", nameof(LapCompletedInfo)).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(CarId), CarId.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(LapTime), LapTime.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(Cuts), Cuts.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(GripLevel), GripLevel.ToString()).AppendLine();
            builder.AppendFormat("    Leaderboard: ");
            for (var i = 0; i < Leaderboard.Count; i++)
            {
                LeaderboardEntry entry = Leaderboard[i];
                builder.AppendFormat("    - {0}: {1}", i, entry).AppendLine();
            }

            builder.AppendFormat("}}").AppendLine();
            return(builder.ToString());
        }
Exemplo n.º 17
0
        public async Task Should_throw_an_exception_when_expected_version_is_out_of_sync()
        {
            // Arrange
            var eventStore = _container.GetRequiredService <IEventStore>();
            var id         = new CarId(_aggregateId.Id);
            var car        = new Car(id);

            car.Travel(10);

            var domainEvents = car.GetUncommittedChanges().ToArray().As <IDomainEvent <IAggregateId>[]>();


            // Act : Save events a first time, and then try again : it should throw an exception the second time
            Func <Task> func = async() => await eventStore.SaveEvents(id, domainEvents, 0);

            await func();

            // Assert
            func.Should().Throw <ConcurrencyException>();
        }
Exemplo n.º 18
0
        public override string ToString()
        {
            var builder = new System.Text.StringBuilder();

            builder.AppendFormat("{0} {{", nameof(Driver)).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(CarId), CarId.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(CarModel), CarModel.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(CarSkin), CarSkin.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(Name), Name.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(Team), Team.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(GUID), GUID.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(IsConnected), IsConnected.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(Position), Position.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(VelocityVector), VelocityVector.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(Speed), Speed.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(SplinePosition), SplinePosition.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(Gear), Gear.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(EngineRPM), EngineRPM.ToString()).AppendLine();
            builder.AppendFormat("}}").AppendLine();
            return(builder.ToString());
        }
Exemplo n.º 19
0
 public override string ToString()
 {
     return(CarId.ToString() + ' ' + OwnerId.ToString() + ' ' + Model + ' '
            + Vis.ToString() + ' ' + Colour + ' ' + Convert.ToDateTime(YearOfIssue).ToString("yyyy") + ' '
            + BodyNumber + ' ' + EngineNumber);
 }
Exemplo n.º 20
0
 public void SetCarWithId(CarId carId)
 {
     CarId = carId;
 }
Exemplo n.º 21
0
 public override string ToString()
 {
     return(WorkroomId.ToString() + ' ' + CarId.ToString() + ' ' + MechanicId.ToString()
            + ' ' + Convert.ToDateTime(ReceiptDate).ToString("dd.MM.yyyy") + Cost.ToString());
 }
Exemplo n.º 22
0
 public CarWithNameDoesNotExist(string name, string exceptId = null)
 {
     this.Name     = name;
     this.ExceptId = string.IsNullOrWhiteSpace(exceptId) ? null : CarId.With(Guid.Parse(exceptId)).Value;
 }
Exemplo n.º 23
0
 public CarsByIds(List <string> ids)
 {
     this.Ids = ids?.Select(id => CarId.With(Guid.Parse(id)).Value).Distinct().ToList() ?? new List <string>();
 }
Exemplo n.º 24
0
        public async Task<IHttpActionResult> GetDetails(CarId id)
        {
            HttpResponseMessage response;
            string content = "";
            var Car = db.Cars.Find(id.id);
            dynamic Recalls;
            var Image = "";

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://www.nhtsa.gov/");
                try
                {
                    response = await client.GetAsync("webapi/api/recalls/vehicle/modelyear/" + Car.model_year +
                                                                                    "/make/" + Car.make +
                                                                                    "/model/" + Car.model_name + "?format=json");
                    content = await response.Content.ReadAsStringAsync();
                }
                catch (Exception e)
                {
                    return InternalServerError(e);
                }
            }
            // Recalls = JsonConvert.DeserializeObject(content);
            Recalls = content;

            var image = new BingSearchContainer(new Uri("https://api.datamarket.azure.com/Bing/search/"));

            image.Credentials = new NetworkCredential("accountKey", "uSZdhD53NSOfNv3g0J1hzgObRqsxmFK8iZXUQ3Y2My0");   //"dwmFt1J2rM45AQXkGTk4ebfcVLNcytTxGMHK6dgMreg"
            var marketData = image.Composite(
                "image",
                    Car.model_year + " " + Car.make + " " + Car.model_name + " " + Car.model_trim,
                    null, null, null, null, null, null, null, null, null, null, null, null, null
                    ).Execute();

            Image = marketData.First().Image.First().MediaUrl;
            return Ok(new { car = Car, recalls = Recalls, image = Image });

        }
Exemplo n.º 25
0
 public override string ToString()
 {
     return(CarId.ToString() + " - " + Brand + ", " + Model + " - " + Price + "$");
 }
Exemplo n.º 26
0
 public override string ToString()
 {
     return($"Plate = {CarId.ToString()} - Name = {Name} - Brand = {Brand}");
 }
Exemplo n.º 27
0
 public UserIsCarOwner(string id)
 {
     this.Id = CarId.With(Guid.Parse(id)).Value;
 }
Exemplo n.º 28
0
 public CarById(string id)
 {
     this.Id = CarId.With(Guid.Parse(id)).Value;
 }
Exemplo n.º 29
0
 internal CarState(CarId id) : this()
 {
     id.ThrowsIfNull(new ArgumentNullException(id));
 }
Exemplo n.º 30
0
 public static Vehicle CreateVehicle(CarId model, Vector3 position) => CreateVehicle((int)model, position);