public async Task AddHouseInCompany(string wmInternalName, WallMaterial wmExternal, Address houseAddress, int countHouseExpected) { var wallMaterial = !string.IsNullOrEmpty(wmInternalName) ? await _uow.WallMaterialRepository.GetSingleAsync(wm => wm.Name == "Кирпич") : wmExternal; var company = await _uow.CompanyRepository.GetCompanyByNameAsync("РакиВДраки"); var newHouse = House.Create(houseAddress, wallMaterial).Value; var res = await _uow.CompanyRepository.AddHouseInCompanyAsync(company.Id, newHouse); await _uow.SaveChangesAsync(); res.Should().BeTrue(); var houses = await _uow.CompanyRepository.GetAllHouseAsync(company.Id); houses.Count.Should().Be(countHouseExpected); var newAddedHouse = await _uow.CompanyRepository.GetHouseAsync(company.Id, houseAddress); newAddedHouse.Should().NotBeNull(); if (wallMaterial == null) { newAddedHouse.WallMaterial.Should().BeNull(); } else { newAddedHouse.WallMaterial.Name.Should().Be(wallMaterial.Name); newAddedHouse.WallMaterial.IsShared.Should().Be(wallMaterial.IsShared); } }
/// <summary> /// Sets the wall material to the one with the highest material /// </summary> private void SetWallMaterial() { WallMaterial wallMaterial = null; int priority = -1; List <Collider2D> colliders = null; if (this.hasWallLeft) { colliders = this.wallSlideColliderLeft.colliders; } else { colliders = this.wallSlideColliderRight.colliders; } foreach (Collider2D collider in colliders) { ObjectMaterial material = collider.gameObject.GetComponent <ObjectMaterial>(); if (material.wallMaterial.priority > priority) { wallMaterial = material.wallMaterial; } } this.wallMaterial = wallMaterial; }
void ChangeCurrentMaterial(int arrayIndex) { mCurrentWallMaterial = mAllWallMaterialGroup[arrayIndex]; for (int index = 0; index < WallLength; index++) { ChangeWallMaterial(index); } }
public async Task AddWallMaterialTask() { var wallMaterial = WallMaterial.Create("Кирпич", true).Value; await _uow.WallMaterialRepository.AddAsync(wallMaterial); await _uow.SaveChangesAsync(); var wallMaterials = await _uow.WallMaterialRepository.ListAsync(); wallMaterials.Count().Should().Be(1); }
public static void Register() { if (Mapper != null) { throw new InvalidOperationException("Метод регистрации AutoMapper не может быть вызванн повторно"); } var config = new MapperConfiguration(cfg => { cfg.CreateMap <EfHouse, House>() .ForMember(dest => dest.Year, opt => opt.MapFrom(src => src.Year)) .ForMember(dest => dest.MetroStation, opt => opt.MapFrom(src => src.MetroStation)) .ForMember(dest => dest.Address, opt => opt.MapFrom(src => src.Address)) .ForMember(dest => dest.WallMaterial, opt => opt.MapFrom(src => src.WallMaterial)) .ReverseMap(); cfg.CreateMap <EfWallMaterial, WallMaterial>() .ConstructUsing(src => WallMaterial.Create(src.Name, src.IsShared).Value) .ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.Name)) .ForMember(dest => dest.IsShared, opt => opt.MapFrom(src => src.IsShared)); cfg.CreateMap <WallMaterial, EfWallMaterial>() .ConstructUsing(src => new EfWallMaterial { Name = src.Name, IsShared = src.IsShared }) .ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.Name)) .ForMember(dest => dest.IsShared, opt => opt.MapFrom(src => src.IsShared)) .ForMember(dest => dest.Houses, opt => opt.Ignore()); //cfg.CreateMap<EfWallMaterial, WallMaterial>() // .ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.Name)) // .ForMember(dest => dest.IsShared, opt => opt.MapFrom(src => src.IsShared)); //cfg.CreateMap<WallMaterial, EfWallMaterial>() // .ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.Name)) // .ForMember(dest => dest.IsShared, opt => opt.MapFrom(src => src.IsShared)) // .ForMember(dest => dest.Houses, opt => opt.Ignore()); cfg.CreateMap <EfCompany, Company>() .ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.Name)) .ForMember(dest => dest.CompanyDetails, opt => opt.MapFrom(src => src.CompanyDetails)) .ForMember(dest => dest.GetHouses, opt => opt.MapFrom(src => src.Houses)); cfg.CreateMap <Company, EfCompany>() .ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.Name)) .ForMember(dest => dest.CompanyDetails, opt => opt.MapFrom(src => src.CompanyDetails)) .ForMember(dest => dest.Houses, opt => opt.MapFrom(src => src.GetHouses)); }); Mapper = config.CreateMapper(); }
public void SetWallMaterial(Apartment apartment, string wallMaterial) { WallMaterial material = _wallMaterialRepository.GetWallMaterialByName(wallMaterial); if (material == null) { material = new WallMaterial() { WallMaterialName = wallMaterial }; _wallMaterialRepository.Add(material); _wallMaterialRepository.SaveChanges(); } apartment.WallMaterial = material; }
public async Task AddWallMaterialsTest() { var wallMaterials = new List <WallMaterial> { WallMaterial.Create("Кирпич", true).Value, WallMaterial.Create("Бетон", true).Value, WallMaterial.Create("Дерево", true).Value }; await _uow.WallMaterialRepository.AddRangeAsync(wallMaterials); await _uow.SaveChangesAsync(); var listWm = (await _uow.WallMaterialRepository.ListAsync()).ToList(); var count = listWm.Count; count.Should().Be(3); }
bool CheckToolMaterial(WallMaterial wallReference) { bool isValid = false; switch (wallReference.thisMaterial) { case WallMaterial.material.Brick: if (currentTool == tool.Trowel && wallReference.thisState == WallMaterial.wallState.broken) { isValid = true; } else if (currentTool == tool.Brick && wallReference.thisState == WallMaterial.wallState.repaired) { isValid = true; } else { isValid = false; } break; case WallMaterial.material.Wood: if (currentTool == tool.Wood && wallReference.thisState == WallMaterial.wallState.broken) { isValid = true; } else if (currentTool == tool.Hammer && wallReference.thisState == WallMaterial.wallState.repaired) { isValid = true; } else { isValid = false; } break; } return(isValid); }
void GetClosestWall() { Collider2D[] theseWalls = Physics2D.OverlapCircleAll(transform.position, checkRadius, wallLayer); Collider2D thisWall = theseWalls[0]; for (int i = 0; i < theseWalls.Length; i++) { if (Vector2.Distance(transform.position, theseWalls[i].transform.position) < Vector2.Distance(transform.position, thisWall.transform.position)) { thisWall = theseWalls[i]; } } WallMaterial wallMaterialReference = thisWall.GetComponent <WallMaterial>(); if (CheckToolMaterial(wallMaterialReference)) { wallMaterialReference.Interact(); } }