public void Deve_Realizar_Post(string address, Environment environment) { FakeContext fakeContext = CreateAndFillContextWithSource(); using (var context = new CentralDeErrorContext(fakeContext.FakeOptions)) { var service = CreateService(fakeContext, context); var newSource = new SourceCreateDTO { Address = address, Environment = environment }; Assert.IsNotNull(newSource); Assert.IsNull(service.Get().Where(x => x.Environment == newSource.Environment.ToString() && x.Address == newSource.Address).FirstOrDefault()); var savedSource = service.Create(newSource); if (savedSource.Success == false) { Assert.AreEqual(false, savedSource.Success); Assert.AreEqual("Fail", savedSource.Message); Assert.IsNull(savedSource.Data); } else { Assert.AreEqual(true, savedSource.Success); Assert.AreEqual("Succesfully registred the source.", savedSource.Message); Assert.IsNotNull(savedSource.Data); } } }
public void NewSource_CanBe_Deleted(int id, string address, Environment environment) { var _newSource = Source.Create(id, address, environment); _newSource.Delete(); Assert.IsTrue(_newSource.Deleted); }
public void Check_Environment_Equals_Development(string address, Environment environment) { var sourceCreateDTO = new SourceCreateDTO { Address = address, Environment = environment }; Assert.AreEqual(environment.ToString(), sourceCreateDTO.Environment.ToString()); }
public void Check_Address_Smaller_Than_Or_Equals_1024_Chars(Environment environment) { var sourceCreateDTO = new SourceCreateDTO { Address = new string('*', 1025), Environment = environment }; sourceCreateDTO.Validate(); Assert.IsTrue(sourceCreateDTO.Invalid); }
public void Check_Address_Bigger_Than_6_Chars(string address, Environment environment) { var sourceCreateDTO = new SourceCreateDTO { Address = address, Environment = environment }; sourceCreateDTO.Validate(); Assert.IsTrue(sourceCreateDTO.Invalid); }
public void Check_Address_Equals_Address(string address, Environment environment) { SourceCreateDTO sourceCreateDTO = new SourceCreateDTO { Address = address, Environment = environment }; sourceCreateDTO.Validate(); Assert.AreEqual("Address", sourceCreateDTO.Address); }
public void Check_Valid_Environment_Between_0_and_Max(string address) { var max = (Environment.GetNames(typeof(Environment)).Length); var sourceCreateDTO = new SourceCreateDTO { Address = address, Environment = (Environment)max }; sourceCreateDTO.Validate(); Assert.IsTrue(sourceCreateDTO.Invalid, $"Max level should be {(max - 1)}"); }
public void Deve_EstaR_Ok_ao_realizar_post(string address, Environment environment) { ISourceRepository fakeService; SourceController controller; CreateController(out fakeService, out controller); var newSource = new SourceCreateDTO { Address = address, Environment = environment }; var result = controller.Register(fakeService, newSource); Assert.IsInstanceOfType(result.Result, typeof(CreatedAtRouteResult)); var actual = (result.Result as CreatedAtRouteResult).Value as ResultDTO; Assert.AreEqual(true, actual.Success); Assert.AreEqual("Succesfully registred the source.", actual.Message); Assert.IsNotNull(actual.Data); }
public void Deve_Falhar_ao_realizar_post_De_Source_Repetido(string address, Environment environment) { ISourceRepository fakeService; SourceController controller; CreateController(out fakeService, out controller); var newSource = new SourceCreateDTO { Address = address, Environment = environment }; var result = controller.Register(fakeService, newSource); Assert.IsInstanceOfType(result.Result, typeof(BadRequestObjectResult)); var actual = (result.Result as BadRequestObjectResult).Value as ResultDTO; Assert.AreEqual(false, actual.Success); Assert.AreEqual("Source already existis.", actual.Message); Assert.IsNull(actual.Data); }
public void DeletedSource_ShouldThrow_InvalidOperationException_When_Deleted(int id, string address, Environment environment) { var _newSource = Source.Create(id, address, environment); _newSource.Delete(); _newSource.Delete(); }
public void NewSource_Deleted_ShouldBeEquals_False(int id, string address, Environment environment) { var _newSource = Source.Create(id, address, environment); Assert.IsFalse(_newSource.Deleted); }
public void NewSource_Environment_ShouldBeDefault(int id, string address, Environment environment) { var _newSource = Source.Create(id, address, environment); Assert.AreEqual("Development", _newSource.Environment.ToString()); }
public void Empty_Address_ShouldReturn_ArgumentNullException(int id, string address, Environment environment) { Source.Create(id, address, environment); }
public void NewSource_Address_ShouldBeAddress(int id, string address, Environment environment) { var _newSource = Source.Create(id, address, environment); Assert.AreEqual("Address", _newSource.Address); }
public void NewSource_ShouldHaveIdEquals_1(int id, string address, Environment environment) { var _newSource = Source.Create(id, address, environment); Assert.AreEqual(1, _newSource.Id); }
public void Deve_Falhar_Ao_Postar_Source_Com_Endereco_E_Ambiente_Ja_Existente(string address, Environment environment) { FakeContext fakeContext = CreateAndFillContextWithSource(); using (var context = new CentralDeErrorContext(fakeContext.FakeOptions)) { var service = CreateService(fakeContext, context); var newSource = new SourceCreateDTO { Address = address, Environment = environment }; var result = service.Create(newSource); Assert.AreEqual(false, result.Success); Assert.AreEqual("Source already existis.", result.Message); Assert.AreEqual(null, result.Data); } }