public CarPartBuilder() { _carPart = BuildValid(); _carPart.Quantity = RandomValueGen.GetRandomInt(); _carPart.CarId = RandomValueGen.GetRandomGuid(); _carPart.PartId = RandomValueGen.GetRandomGuid(); }
public void Test_GenerateValidValue_WhenPropTypeGuid_ShouldReturnItemInListAsGuid() { //---------------Set up test pack------------------- Type guidPropType = typeof(Guid); IPropDef def = new PropDefFake { PropertyType = guidPropType }; RandomValueGen.GetRandomGuid().ToString(); var dictionary = new Dictionary <string, string> { { "fdafasd", RandomValueGen.GetRandomGuid().ToString() } }; def.LookupList = new SimpleLookupList(dictionary); //---------------Assert Precondition---------------- Assert.IsNotNull(def.LookupList); Assert.AreEqual(1, def.LookupList.GetLookupList().Count); Assert.AreSame(guidPropType, def.PropertyType); //---------------Execute Test ---------------------- object value = new ValidValueGeneratorLookupList(def).GenerateValidValue(); //---------------Test Result ----------------------- Assert.IsNotNull(value); Assert.IsInstanceOf(guidPropType, value, value + " should be of type guid"); }
public void Delete_GivenValidCarId_ShouldCallGetCarById() { //---------------Set up test pack------------------- var id = RandomValueGen.GetRandomGuid(); var carRepository = Substitute.For <ICarRepository>(); var carController = CreateBuilder() .WithCarRepository(carRepository) .Build(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var result = carController.Delete(id); //---------------Test Result ----------------------- carRepository.Received().GetCarBy(id); }
public void Edit_Get_GivenValidCarId_ShouldCallGetCarByIdFromRepo() { //---------------Set up test pack------------------- var id = RandomValueGen.GetRandomGuid(); var partRepository = Substitute.For <IPartRepository>(); var partController = CreateBuilder() .WithCarRepository(partRepository) .Build(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var result = partController.Edit(id); //---------------Test Result ----------------------- partRepository.Received().GetPartBy(id); }