Character(string name, string role, string school, CharacterHouse house, string patronus) : base(Guid.NewGuid()) { Name = name; Role = role; School = school; House = house; HouseId = house.Id; Patronus = patronus; }
static void VerifyArguments(string name, string role, string school, CharacterHouse house, Response <Character> response) { if (string.IsNullOrEmpty(name)) { response.WithBusinessError(nameof(name), $"{nameof(name)} is invalid"); } if (string.IsNullOrEmpty(role)) { response.WithBusinessError(nameof(role), $"{nameof(role)} is invalid"); } if (string.IsNullOrEmpty(school)) { response.WithBusinessError(nameof(school), $"{nameof(school)} is invalid"); } if (house == null) { response.WithBusinessError(nameof(house), $"{nameof(house)} is invalid"); } }
public Response Update(string name, string role, string school, CharacterHouse house, string patronus) { var response = Response <Character> .Create(); VerifyArguments(name, role, school, house, response); if (response.HasError) { return(response); } if (!House.Id.Equals(house.Id)) { House.Delete(); } Name = name; Role = role; School = school; House = house; HouseId = house.Id; Patronus = patronus; return(response); }
public static Response <Character> Create(string name, string role, string school, CharacterHouse house, string patronus) { var response = Response <Character> .Create(); VerifyArguments(name, role, school, house, response); if (response.HasError) { return(response); } return(response.SetValue(new Character(name, role, school, house, patronus))); }
public Model.Character CharacterFake(string name = null, string role = null, string school = null, Model.CharacterHouse house = null, string patronus = null) { var houseFake = Builder <HouseModel> .CreateNew() .Build(); var characterHouseFake = Builder <Model.CharacterHouse> .CreateNew() .With(x => x.House, houseFake) .Build(); return(Builder <Model.Character> .CreateNew() .With(x => x.Name, name ?? "Any Name") .With(x => x.Role, role ?? "Any Role") .With(x => x.School, school ?? "Any School") .With(x => x.House, house ?? characterHouseFake) .With(x => x.Patronus, patronus ?? "Any Animal") .Build()); }
public void TestInitialize() { _house = CharacterHouseFake(); }