@@ -17,6 +17,7 @@ namespace chocolatey.tests.integration.scenarios
1717{
1818 using System ;
1919 using System . Collections . Concurrent ;
20+ using System . Collections . Generic ;
2021 using System . IO ;
2122 using System . Linq ;
2223 using System . Threading ;
@@ -636,17 +637,136 @@ public override void Context()
636637 base . Context ( ) ;
637638 var packagesConfig = "{0}\\ context\\ testing.packages.config" . format_with ( Scenario . get_top_level ( ) ) ;
638639 Configuration . PackageNames = Configuration . Input = packagesConfig ;
640+ Scenario . add_packages_to_source_location ( Configuration , "hasdependency.1.0.0*" + Constants . PackageExtension ) ;
641+ Scenario . add_packages_to_source_location ( Configuration , "isdependency.1.0.0*" + Constants . PackageExtension ) ;
642+ Scenario . add_packages_to_source_location ( Configuration , "isexactversiondependency*" + Constants . PackageExtension ) ;
643+ Scenario . add_packages_to_source_location ( Configuration , "upgradepackage*" + Constants . PackageExtension ) ;
644+ Configuration . UpgradeCommand . FailOnNotInstalled = false ;
639645 }
640646
641647 public override void Because ( )
642648 {
649+ Results = Service . upgrade_run ( Configuration ) ;
643650 }
644651
645652 [ Fact ]
646- [ ExpectedException ( typeof ( ApplicationException ) ) ]
647- public void should_throw_an_error_that_it_is_not_allowed ( )
653+ public void should_install_where_install_location_reports ( )
648654 {
649- Results = Service . upgrade_run ( Configuration ) ;
655+ foreach ( var packageResult in Results )
656+ {
657+ if ( packageResult . Value . Name . is_equal_to ( "missingpackage" ) ) continue ;
658+ Directory . Exists ( packageResult . Value . InstallLocation ) . ShouldBeTrue ( ) ;
659+ }
660+ }
661+
662+ [ Fact ]
663+ public void should_install_expected_packages_in_the_lib_directory ( )
664+ {
665+ var packagesExpected = new List < string > { "installpackage" , "hasdependency" , "isdependency" , "upgradepackage" } ;
666+ foreach ( var package in packagesExpected )
667+ {
668+ var packageDir = Path . Combine ( Scenario . get_top_level ( ) , "lib" , package ) ;
669+ Directory . Exists ( packageDir ) . ShouldBeTrue ( ) ;
670+ }
671+ }
672+
673+ [ Fact ]
674+ public void should_install_the_dependency_in_the_lib_directory ( )
675+ {
676+ var packageDir = Path . Combine ( Scenario . get_top_level ( ) , "lib" , "isdependency" ) ;
677+ Directory . Exists ( packageDir ) . ShouldBeTrue ( ) ;
678+ }
679+
680+ [ Fact ]
681+ public void should_contain_a_warning_message_that_it_upgraded_3_out_of_6_packages_successfully ( )
682+ {
683+ bool upgradedSuccessfully = false ;
684+ foreach ( var message in MockLogger . MessagesFor ( LogLevel . Warn ) . or_empty_list_if_null ( ) )
685+ {
686+ if ( message . Contains ( "3/6" ) ) upgradedSuccessfully = true ;
687+ }
688+
689+ upgradedSuccessfully . ShouldBeTrue ( ) ;
690+ }
691+
692+ [ Fact ]
693+ public void should_contain_a_message_that_upgradepackage_with_an_expected_specified_version_was_not_installed ( )
694+ {
695+ bool expectedMessage = false ;
696+ foreach ( var message in MockLogger . MessagesFor ( LogLevel . Info ) . or_empty_list_if_null ( ) )
697+ {
698+ if ( message . Contains ( "upgradepackage v1.0.0 is the latest version available based on your source" ) ) expectedMessage = true ;
699+ }
700+
701+ expectedMessage . ShouldBeTrue ( ) ;
702+ }
703+
704+ [ Fact ]
705+ public void should_have_a_successful_package_result_for_all_but_expected_missing_package ( )
706+ {
707+ foreach ( var packageResult in Results )
708+ {
709+ if ( packageResult . Value . Name . is_equal_to ( "missingpackage" ) ) continue ;
710+
711+ packageResult . Value . Success . ShouldBeTrue ( ) ;
712+ }
713+ }
714+
715+ [ Fact ]
716+ public void should_not_have_a_successful_package_result_for_missing_package ( )
717+ {
718+ foreach ( var packageResult in Results )
719+ {
720+ if ( ! packageResult . Value . Name . is_equal_to ( "missingpackage" ) ) continue ;
721+
722+ packageResult . Value . Success . ShouldBeFalse ( ) ;
723+ }
724+ }
725+
726+ [ Fact ]
727+ public void should_not_have_inconclusive_package_result_for_all_but_expected_install_and_upgrade_packages ( )
728+ {
729+ foreach ( var packageResult in Results )
730+ {
731+ // These two packages don't upgrade because there is no newer version available
732+ if ( packageResult . Value . Name . is_equal_to ( "installpackage" ) || packageResult . Value . Name . is_equal_to ( "upgradepackage" ) )
733+ packageResult . Value . Inconclusive . ShouldBeTrue ( ) ;
734+ else
735+ packageResult . Value . Inconclusive . ShouldBeFalse ( ) ;
736+ }
737+ }
738+
739+ [ Fact ]
740+ public void should_not_have_warning_package_result ( )
741+ {
742+ foreach ( var packageResult in Results )
743+ {
744+ packageResult . Value . Warning . ShouldBeFalse ( ) ;
745+ }
746+ }
747+
748+ [ Fact ]
749+ public void should_specify_config_file_is_being_used_in_message ( )
750+ {
751+ bool expectedMessage = false ;
752+ foreach ( var message in MockLogger . MessagesFor ( LogLevel . Info ) . or_empty_list_if_null ( ) )
753+ {
754+ if ( message . Contains ( "Upgrading from config file:" ) ) expectedMessage = true ;
755+ }
756+
757+ expectedMessage . ShouldBeTrue ( ) ;
758+ }
759+
760+ [ Fact ]
761+ public void should_print_out_package_from_config_file_in_message ( )
762+ {
763+ bool expectedMessage = false ;
764+ foreach ( var message in MockLogger . MessagesFor ( LogLevel . Info ) . or_empty_list_if_null ( ) )
765+ {
766+ if ( message . Contains ( "installpackage" ) ) expectedMessage = true ;
767+ }
768+
769+ expectedMessage . ShouldBeTrue ( ) ;
650770 }
651771 }
652772
0 commit comments