public ViewRedactionPage() { InitializeComponent(); context = new PhoneContext(); vServise = new ValidationServise(errorLabel); service = new RedactionService(context); }
public RedactionPage() { InitializeComponent(); context = new PhoneContext(); service = new RedactionService(context); personalGrid.ItemsSource = context.PersPhone.ToList(); corporativeGrid.ItemsSource = context.CorpPhones.ToList(); }
public void CorpRedaction_NotValidData_RedactionSaved() { var mockSet = new Mock <DbSet <CorporativeTelephone> >(); var mockContext = new Mock <PhoneContext>(); mockContext.Setup(m => m.CorpPhones).Returns(mockSet.Object); mockSet.Setup(m => m.Find(It.IsAny <int>())).Returns(new CorporativeTelephone { PhoneNumber = "1234567890000", Id = 5 }); RedactionService service = new RedactionService(mockContext.Object); service.CorpRedaction(new CorporativeTelephone(), new Data(), false); mockContext.Verify(m => m.SaveChanges(), Times.Never()); }
public void PersonalRedaction_ValidData_RedactionSaved() { var mockSet = new Mock <DbSet <PersonalTelephone> >(); var mockContext = new Mock <PhoneContext>(); mockContext.Setup(m => m.PersPhone).Returns(mockSet.Object); mockSet.Setup(m => m.Find(It.IsAny <int>())).Returns(new PersonalTelephone { PhoneNumber = "1234567890000", Id = 5 }); RedactionService service = new RedactionService(mockContext.Object); service.PersonalRedaction(new PersonalTelephone(), new Data(), true); mockContext.Verify(m => m.SaveChanges(), Times.Once()); }
public void GetPhone_pGridVisible_NotSelected_ReturnsNullAndNull() { List <PersonalTelephone> sourse = new List <PersonalTelephone>() { new PersonalTelephone { PhoneNumber = "1234567890123" } }; DataGrid pGrid = new DataGrid() { ItemsSource = sourse, SelectedItem = null, Visibility = Visibility.Visible }; DataGrid cGrid = new DataGrid(); RedactionService service = new RedactionService(); RedactionData result = service.GetPhone(pGrid, cGrid); Assert.IsNull(result.Phone); Assert.AreEqual(0, result.Table); }
public void GetPhone_pGridNotVisible_NotSelected_ReturnsNullAndOne() { List <CorporativeTelephone> sourse = new List <CorporativeTelephone>() { new CorporativeTelephone { PhoneNumber = "1234567890123" } }; DataGrid pGrid = new DataGrid() { Visibility = Visibility.Collapsed }; DataGrid cGrid = new DataGrid() { ItemsSource = sourse, SelectedItem = null }; RedactionService service = new RedactionService(); RedactionData result = service.GetPhone(pGrid, cGrid); Assert.IsNull(result.Phone); Assert.AreEqual(0, result.Table); }
public RedactionController() { _connectionString = ConfigurationManager.ConnectionStrings["LibraryContext"].ConnectionString; _redactionService = new RedactionService(_connectionString); }