public void Validate_Throws_ServiceValidationExeption() { Mock <IServiceProvider> serviceProvider = new Mock <IServiceProvider>(); DownPaymentViewModel viewModel = new DownPaymentViewModel(); var service = new Lib.Services.ValidateService.ValidateService(serviceProvider.Object); Assert.Throws <ServiceValidationException>(() => service.Validate(viewModel)); }
public void Should_Succes_Instantiate_validateService() { var serviceProviderMock = new Mock <IServiceProvider>(); var service = new Lib.Services.ValidateService.ValidateService(serviceProviderMock.Object); CreditBalanceViewModel viewModel = new CreditBalanceViewModel(); service.Validate(viewModel); Assert.NotNull(service); }
public void Validate_Throws_ServiceValidationExeption() { //Setup Mock <IServiceProvider> serviceProvider = new Mock <IServiceProvider>(); Mock <IRoleService> IRoleServiceMock = new Mock <IRoleService>(); IRoleServiceMock.Setup(s => s.CheckDuplicate(It.IsAny <int>(), It.IsAny <string>())).Returns(true); serviceProvider.Setup(S => S.GetService(typeof(IRoleService))).Returns(IRoleServiceMock.Object); RoleViewModel viewModel = new RoleViewModel(); //Act var service = new Lib.Services.ValidateService.ValidateService(serviceProvider.Object); //Assert Assert.Throws <ServiceValidationException>(() => service.Validate(viewModel)); }
public void Validate_Succes() { var serviceProviderMock = new Mock <IServiceProvider>(); var sut = new Lib.Services.ValidateService.ValidateService(serviceProviderMock.Object); var model = new Mock <dynamic>(); try { sut.Validate(model); return; // indicates success } catch (Exception ex) { Assert.True(false, "gagal"); } }