private void CheckTransponder(ITvCardHandler tvcard, IChannel tuningDetail, TvBusinessLayer layer, IUser user)
 {
   var cardAlloc = new AdvancedCardAllocation(layer, _tvController);
   cardAlloc.CheckTransponder(user, tvcard, tuningDetail);
 }      
    private void TestWrongTuningDetailForCardForFTAChannel(CardType cardType)
    {
      Dictionary<int, ITvCardHandler> cards = new Dictionary<int, ITvCardHandler>();
      List<IChannel> tuningDetails = new List<IChannel>();

      IUser user = Fakes.FakeUser();
      TvBusinessLayer businessLayer = Fakes.FakeTvBusinessLayer();;
      TVController controller = Fakes.FakeTVController();

      //we need to pick a different cardtype here-
      CardType cardTypeDifferent = cardType;
      switch (cardType)
      {
        case CardType.DvbT:
          cardTypeDifferent = CardType.DvbC;
          break;

        case CardType.DvbC:
          cardTypeDifferent = CardType.DvbS;
          break;

        case CardType.DvbS:
          cardTypeDifferent = CardType.DvbT;
          break;
      }
      IChannel tuningDetail1 = GetFTATuningDetailBasedOnCardType(cardTypeDifferent);

      tuningDetails.Add(tuningDetail1);

      DVBCardMocks dvbCardMocks = GetCardMockByCardType(cardType, tuningDetails, user);
      ITvCardHandler cardHandler1 = dvbCardMocks.GetMockedCardHandler();
      //ITvCardHandler cardHandler1 = DVBTCardMocks.AddIdleFTADVBTCard(tuningDetail1, user);
      cards.Add(dvbCardMocks.CardId, cardHandler1);


      ChannelMap channelMap;
      Channel channel = ChannelMocks.GetChannel(out channelMap);
      Isolate.WhenCalled(() => businessLayer.GetTuningChannelsByDbChannel(channel)).WillReturn(tuningDetails);
      TVControllerMocks.CardPresent(cardHandler1.DataBaseCard.IdCard, controller);

      SetupChannelMapping(cardHandler1, channelMap, businessLayer, channel);

      AdvancedCardAllocation allocation = new AdvancedCardAllocation(businessLayer, controller);

      TvResult result;
      List<CardDetail> availCards = allocation.GetFreeCardsForChannel(cards, channel, ref user, out result);

      Assert.AreEqual(0, availCards.Count, "The number of cards returned is not as expected");
    }
    public void Test2AvailIdleDVBTCardsForFTAChannel()
    {
      Dictionary<int, ITvCardHandler> cards = new Dictionary<int, ITvCardHandler>();
      List<IChannel> tuningDetails = new List<IChannel>();

      IUser user = Fakes.FakeUser();
      TvBusinessLayer businessLayer = Fakes.FakeTvBusinessLayer();
      TVController controller = Fakes.FakeTVController();
      IChannel tuningDetail1 = GetFTATuningDetailBasedOnCardType(CardType.DvbT);      

      tuningDetails.Add(tuningDetail1);

      DVBCardMocks dvbCardMocks1 = GetCardMockByCardType(CardType.DvbT, tuningDetails, user);
      DVBCardMocks dvbCardMocks2 = GetCardMockByCardType(CardType.DvbT, tuningDetails, user);
      dvbCardMocks1.Idle = true;
      dvbCardMocks2.Idle = true;

      ITvCardHandler cardHandler1 = dvbCardMocks1.GetMockedCardHandler();
      cards.Add(dvbCardMocks1.CardId, cardHandler1);

      ITvCardHandler cardHandler2 = dvbCardMocks1.GetMockedCardHandler();
      cards.Add(dvbCardMocks2.CardId, cardHandler1);

      ChannelMap channelMap;
      Channel channel = ChannelMocks.GetChannel(out channelMap);
      Isolate.WhenCalled(() => businessLayer.GetTuningChannelsByDbChannel(channel)).WillReturn(tuningDetails);      

      TVControllerMocks.CardPresent(cardHandler1.DataBaseCard.IdCard, controller);
      TVControllerMocks.CardPresent(cardHandler2.DataBaseCard.IdCard, controller);

      SetupChannelMapping(cardHandler1, channelMap, businessLayer, channel);
      SetupChannelMapping(cardHandler2, channelMap, businessLayer, channel);

      AdvancedCardAllocation allocation = new AdvancedCardAllocation(businessLayer, controller);

      TvResult result;
      List<CardDetail> availCards = allocation.GetFreeCardsForChannel(cards, channel, ref user, out result);

      Assert.AreEqual(2, availCards.Count, "The number of cards returned is not as expected");
    }
    private void TestOneAvailLockedCardForFTAChannel(CardType cardType)
    {
      Dictionary<int, ITvCardHandler> cards = new Dictionary<int, ITvCardHandler>();
      List<IChannel> tuningDetails = new List<IChannel>();

      IUser user = Fakes.FakeUser();
      TvBusinessLayer businessLayer = Fakes.FakeTvBusinessLayer();;
      TVController controller = Fakes.FakeTVController();

      IChannel tuningDetail1 = GetFTATuningDetailBasedOnCardType(cardType);
      tuningDetails.Add(tuningDetail1);

      DVBCardMocks dvbCardMocks = GetCardMockByCardType(cardType, tuningDetails, user);
      dvbCardMocks.Idle = false;
      ITvCardHandler cardHandler1 = dvbCardMocks.GetMockedCardHandler();
      cards.Add(dvbCardMocks.CardId, cardHandler1);

      ChannelMap channelMap;
      Channel channel = ChannelMocks.GetChannel(out channelMap);
      Isolate.WhenCalled(() => businessLayer.GetTuningChannelsByDbChannel(channel)).WillReturn(tuningDetails);
      TVControllerMocks.CardPresent(cardHandler1.DataBaseCard.IdCard, controller);

      SetupChannelMapping(cardHandler1, channelMap, businessLayer, channel);

      AdvancedCardAllocation allocation = new AdvancedCardAllocation(businessLayer, controller);

      TvResult result;
      List<CardDetail> availCards = allocation.GetFreeCardsForChannel(cards, channel, ref user, out result);

      Assert.AreEqual(1, availCards.Count, "The number of cards returned is not as expected");
      Assert.AreEqual(availCards[0].SameTransponder, false, "same transponder not as expected");
    }