public void Should_UpdatePreferences() { var teams = CreateDataContext().AddTeams(5); foreach (var t in teams) { var prefRes = GetRepo <TeamRepository>() .ForActiveOrg(t.OrgId) .GetPreferences(t.Id); Assert.False(prefRes.HasError); var model = prefRes.Value; var emptyModel = new ModelTeamPreferences() { TeamId = t.Id, OrgId = t.OrgId }; Assert.True(emptyModel.Equals(prefRes.Value)); TestFactory.Update(model); Assert.False(GetRepo <TeamRepository>() .ForActiveOrg(t.OrgId) .UpdatePreferences(model) .HasError); prefRes = GetRepo <TeamRepository>() .ForActiveOrg(t.OrgId) .GetPreferences(t.Id); Assert.False(prefRes.HasError); Assert.True(model.Equals(prefRes.Value)); } }
public void Should_DeleteTeamsAndPreferences() { var teams = CreateDataContext().AddTeams(5); CreateDataContext().AddTeamPreferences(); Assert.True(CreateDataContext() .Preferences .ToList() .Count == teams.Count); foreach (var t in teams) { Assert.False(GetRepo <TeamRepository>() .ForActiveOrg(t.OrgId) .Delete(t.Id) .HasError); var prefCount = CreateDataContext() .Preferences .ToList() .Count; var teamCount = CreateDataContext() .Teams .ToList() .Count; Assert.True(prefCount == teamCount); var model = GetRepo <TeamRepository>() .ForActiveOrg(t.OrgId) .GetPreferences(t.Id); Assert.False(model.HasError); var emptyModel = new ModelTeamPreferences() { OrgId = t.OrgId, TeamId = t.Id }; Assert.True(emptyModel.Equals(model.Value)); } Assert.Empty(CreateDataContext() .Preferences .ToList()); }
public void ShouldNot_UpdatePreferencesWhenBadTeamId() { var teams = CreateDataContext().AddTeams(5); foreach (var t in teams) { var prefRes = GetRepo <TeamRepository>() .ForActiveOrg(t.OrgId) .GetPreferences(t.Id); Assert.False(prefRes.HasError); var model = prefRes.Value; var emptyModel = new ModelTeamPreferences() { TeamId = t.Id, OrgId = t.OrgId }; Assert.True(emptyModel.Equals(prefRes.Value)); TestFactory.Update(model); Assert.True(GetRepo <TeamRepository>() .ForActiveOrg(0) .UpdatePreferences(model) .Error .Code == ErrorCode.BadGetTeam); model.TeamId = TestFactory.GetRandomUShort(1000) + 1000; Assert.True(GetRepo <TeamRepository>() .ForActiveOrg(t.OrgId) .UpdatePreferences(model) .Error .Code == ErrorCode.BadGetTeam); } }